/

Event

Perform analysis and checks on Kubernetes Events found in the cluster


The Event analyzer checks if an Event exists within the cluster resources in a given namespace.

The analyzer uses data from the clusterResources collector. The clusterResources collector is automatically added and will always be present.

The target Event can be identified by Reason, Kind or a regular expression matching the Event Message.

The outcomes on this analyzer will be processed in order, and execution will stop after the first outcome that is truthy.

The analyzer also has access to all fields in the Event object, Go templating can be used for dynamic message. E.g. {{ .Reason }} {{ .InvovledObject.Name }}

Parameters

reason: (Required) Event Reason. For example, InvalidDiskCapacity. Possible reasons list can be referred from Kubernetes source code

namespace: (Optional) The namespace to look for the deployment in. If specified, analysis will be limited to deployments in this namespace.

kind: (Optional) The REST resource the Event represents. For example,Pod

regex: (Optional) A regular expression pattern to test against Event Message

Example Analyzer Definition

apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
  name: preflight-sample-event
spec:
  analyzers:
    - event:
        checkName: event-oom-check
        namespace: default
        reason: "OOMKilled"
        kind: Pod
        outcomes:
          - fail:
              when: "true"
              message: Event {{ .Reason }} by object {{ .InvolvedObject.Name }} kind {{ .InvolvedObject.Kind }} has message {{ .Message }}
          - fail:
              when: "false"
              message: No OOMKilled event detected
Edit on GitHub