Monitor Kubernetes/OpenShift events
Prerequisites
- For Dynatrace Managed customers, Dynatrace Managed 1.234+
- ActiveGate version 1.223+
- Enable the latest version of Dynatrace log monitoring
- Make sure monitoring is enabled on your cluster, and turn on Monitor events in the settings of your Kubernetes cluster.
Kubernetes events monitoring for analysis and alerting
For full observability into your Kubernetes events, automatic Davis analysis, and custom alerting, you need to enable Kubernetes event monitoring.
You can enable this feature for specific Kubernetes clusters. See below for instructions.
Enable event monitoring for individual clusters
- In the Dynatrace menu, go to Kubernetes.
- Find your Kubernetes cluster, and then select More (…) > Settings in the Actions column.
- Change Monitor events as needed, and then select Save changes.
View events
After enabling the Kubernetes event monitoring, you can view and analyze events from the Kubernetes cluster. On your Kubernetes cluster details page, go to Events.
You can filter events by:
- Timeframe: select one of the timeframes in the chart to view open events for that timeframe
- Specific events: select one of the group labels below the chart to view specific events
For more information about an event, select Details for the event.
Note: Kubernetes events are associated with Kubernetes entities. An event is displayed on the respective entity page and on related entity pages. For example, pod events are displayed on the cluster, namespace, workload, and pod details page.
You can also view events on the Log viewer page (in the Dynatrace menu, go to Logs), which allows for advanced search and filtering.
Filter events
Filtering follows the Kubernetes-established format of field selectors, so events can be chosen based on event resource fields such as source.component
, type
, or involvedObject
.
Set up event field selectors optional
Filtering is turned off by default, which means that all events are ingested. For maximum flexibility and fine-grained control over the events you want to ingest from Kubernetes, you can set up multiple field selectors for every Kubernetes environment.
To set up field selectors
- In the Dynatrace menu, go to Kubernetes.
- Find your cluster, and then select More (…) > Settings in the Actions column.
- Turn on Filter events.
- Select Add events field selector.
- Select Save changes.
Note: You can create a maximum of 20 event filter rules per Kubernetes cluster.
You can also define the event field selectors via Dynatrace API.
Syntax
The field selector syntax is the same as the one used in Kubernetes.
An event field selector expression can have up to 10 selectors separated by commas. Events matching all comma-separated selectors will be ingested. The logical operator is AND
.
If you set a field selector expression to involvedObject.namespace=hipster-shop,type=Warning
, the expression will store all the events related to the namespace hipster-shop
that are of type Warning
.
If you separate the expression into two independent field selectors, you'll get all events for namespace hipster-shop
and all events of type Warning
. The logical operator in this case is OR
.
Examples
Events field selectors | Field selector expression |
---|---|
Get all Node events | involvedObject.kind=Node |
Get all Warning events | type=Warning |
Get all Pod events | involvedObject.kind=Pod |
Get all events of objects related to a specific namespace | involvedObject.namespace=<your_namespace> (Make sure to replace <your_namespace> with the name of your own namespace) |
Get all BackOff events for pods across all namespaces | reason=BackOff |
CLI equivalent command
Alternatively, you can select an event field from the CLI as shown in the example below.
kubectl get events --all-namespaces --field-selector involvedObject.namespace=hipster-shop,type=Warning
Monitor important events
When problems with applications, microservices, or infrastructure are detected, Davis performs root cause analysis on all important Kubernetes events for nodes, namespaces, workloads, and pods.
To have Davis look for Kubernetes events during the root cause analysis for an application issue
- In the Dynatrace menu, go to Kubernetes.
- Find your cluster, and then select More (…) > Settings in the Actions column.
- Turn on Filter events.
- Turn on Include important events.
- Select Save changes.
Charting and custom alerting for events
Charting and custom alerting for events allow you to trigger alerts whenever Kubernetes events occur (for example, always alert in case of a BackOff
event).
To trigger alerts for Kubernetes events
- Create a log metric based on the events for which you want to chart or receive alerts. Be sure to add the dimensions you want for later use (for splitting or filtering). For example, if you need to chart or configure an alert only for a specific namespace, you need to add the namespace as a dimension of the log metric.
Note: New log metrics appear in Dynatrace only after the first matching event is ingested.
- Use the log metric created in the previous step to either chart it using Data explorer or set up an alert using custom event for alerting.
Licensing
To estimate the number of events that consume DDUs, you can query the dsfm:active_gate.kubernetes.events.processed
metric, which provides information about the number of events that are being ingested into Dynatrace per Kubernetes cluster.
Example query for a 24-hour timeframe:
dsfm:active_gate.kubernetes.events.processed:splitBy("dt.entity.kubernetes_cluster"):sum:auto:sort(value(sum,descending)):limit(10)
Note: DDU consumption applies to Kubernetes event monitoring. For details, see DDUs for custom Davis events.