Create Alert Rules for Events/Auditing

Create Alert Rules for Events/Auditing

This section describes how to define alert rules for Kubernetes native events and Kubernetes/KubeSphere audit events.

Prerequisites

  • You should have the platform-admin role on the KubeSphere platform.

  • WhizardTelemetry Events Alerting should have been extension installed and enabled.

Steps

  1. On any cluster node, create a yaml file to define alert rules for events and auditing in that cluster.

    Click here to view a complete example of alert rules. Refer to Parameter Description to set the parameters for the alert rules.

    A simple example is as follows:

    apiVersion: logging.whizard.io/v1alpha1
    kind: ClusterRuleGroup
    metadata:
      name: example-auditing-rule
      namespace: kubesphere-logging-system
    spec:
      type: auditing
      rules:
        - desc: all action not need to be audit
          expr:
            kind: list
            list:
              - get
              - list
              - watch
          name: ignore-action
        - desc: all operator need to be audit
          expr:
            kind: list
            list:
              - create
              - delete
              - update
              - patch
          name: action
        - desc: pod
          expr:
            kind: macro
            macro: ObjectRef.Resource="pods"
          name: pod
        - desc: service
          expr:
            kind: macro
            macro: ObjectRef.Resource="services"
          name: service
        - desc: the alias of the user related to audit event
          expr:
            alias: User.username
            kind: alias
          name: user
  2. Run the following command to create the CRD (Custom Resource Definition).

    kubectl apply -f xxx.yaml  # Replace with the name of the yaml file
  3. After successful execution, search for ClusterRuleGroup on the Cluster CRDs page.

  4. Click ClusterRuleGroup to enter the details page and view, edit, or delete the alert rules on the right side of the page.

Receive the latest news, articles and updates from KubeSphere


Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.

What’s on this Page