DEV Community

Cover image for Kubernetes events: how to read, keep and alert on them
Span Observer
Span Observer

Posted on Originally published at span.observer

Kubernetes events: how to read, keep and alert on them

A pod restarts in a loop at 3 a.m., you open your terminal at 9 a.m., and the reason is gone. Kubernetes events are the cluster’s logbook: they say an image could not be pulled, a probe failed, a node ran short of memory. But they vanish fast. This article starts from the operational decision behind that: what do you keep, where, and what should wake you up?

The facts come from the Kubernetes documentation, the OpenTelemetry Collector contrib repository and the kube-apiserver reference, read on 12 November 2026. I did not run a cluster for this article: anything unverified is flagged in the text.

If you already alert on nodes and quotas, see Kubernetes alerts on nodes, pods and quotas. Events supply the « why » that metrics cannot.

Kubernetes events: what they actually contain

An Event is an API object, just like a pod. The API reference describes it as a report of a state change. Each event names the object concerned (involvedObject), a short machine-readable cause (reason), a human message (message) and a type, Normal or Warning. The page states that new types may be added, so do not write an « else » branch that assumes only these two exist.

Other fields help with deduplication. count tallies repeats, firstTimestamp and lastTimestamp bound the period, and series groups repeated occurrences of one event. The emitting controller appears in reportingComponent and reportingInstance, for example the kubelet on a given node.

The most important point is a warning in the documentation: events have a limited retention time, and consumers should not rely on their timing, reason or continued existence. They are supplementary, best-effort data. Keep one rule in mind: an event helps you understand, it never proves anything.

How long do events remember?

The kube-apiserver reference gives the default. The --event-ttl option sets the « amount of time to retain events » and defaults to 1h0m0s.

Extract of the kube-apiserver help: the --event-ttl option, default 1h0m0s

One hour, then. On a cluster you administer, you can change it. On a managed service you usually cannot reach control-plane flags. I did not check what each provider allows, so read its documentation before counting on a longer value.

The practical consequence: a night-time outage can be diagnosed from events only if someone copied them elsewhere. That is the job of an export.

Reading events before exporting them

Start with what your team does by hand, because the export will reuse the same sorting logic.

  1. List a namespace’s events: kubectl get events -n my-namespace.
  2. Keep the anomalies: kubectl get events -n my-namespace --field-selector type=Warning.
  3. Look at one object with the subcommand kubectl events --for pod/my-pod.

I quote these commands from my knowledge of the CLI: check the options with kubectl events --help on your version. For a failing pod, kubectl describe pod also prints recent events at the bottom of its output.

This manual sorting sets your policy. You nearly always want to keep Warning events and drop most Normal ones (scheduling, start-up, successful image pulls). Keep the Normal ones if you want to rebuild a deployment timeline.

Keeping Kubernetes events with the Collector

The contrib Collector ships a receiver called k8s_events (folder k8seventsreceiver in the repository). Its README declares alpha stability for logs, availability in the contrib and k8s distributions, and collection of « all the new or updated events » from the Kubernetes API server. It produces logs: one event becomes one log record.

Here is the README example, trimmed to the essentials. Replace the endpoint with your own.

Collector configuration with the k8s\_events receiver, the file\_storage extension and a logs pipeline to an OTLP exporter

Three settings deserve an explanation.

  • namespaces: all by default. List the ones that matter to cut volume.
  • storage: a storage extension that keeps the latest resourceVersion. After a restart the receiver resumes where it stopped and avoids duplicates. The README warns against a node-local volume if the pod can move.
  • auth_type: serviceAccount by default. The service account needs the get, list and watch verbs on the events resource.

The README also mentions k8s_leader_elector, useful if you run several replicas without wanting double collection. To understand receivers and pipelines, see the contrib Collector components.

Cutting the noise: deduplication

A failing readiness probe produces event updates continuously. The README describes the dedup_interval option, off by default (value 0). With 5m, the receiver emits the first update per event UID, then drops later ones until the interval ends. Additions are always emitted and deletions are excluded. The repeat count remains available in the k8s.event.count attribute.

Two limits are written in the README: the deduplication state lives in memory, so a restart resets it; and it only applies to updates. I did not verify since which Collector version this option exists: check the release notes of yours before enabling it.

What each log carries

The receiver’s code writes resource attributes (k8s.object.*) and log attributes (k8s.event.*). These names come from the current main branch code, not from a stable semantic convention: treat them as liable to change.

List of the k8s.object and k8s.event attributes written by the k8s\_events receiver, taken from its source code

So you get the reason, the object, the controller and the counter. That is enough to filter on k8s.event.reason in your log tool. To route these logs to your platform, the logic matches a container log: see Kubernetes log shipping with Fluent Bit to compare approaches.

Alerting on events: a few reasons worth a wake-up

Alerting on every Warning wears out the on-call. Pick reasons that signal unavailability, and require recurrence.

  • Repeated BackOff on one pod: a restart or image-pull loop.
  • FailedScheduling: the pod finds no node, often for lack of resources.
  • Unhealthy: a probe fails.
  • FailedMount: a volume does not mount.

These reasons are common, but the API does not fix the list: they come from the components that emit them, and I did not verify each one. Collect the ones your cluster produces before building a rule.

The typical rule: « more than N logs with this reason on the same object within 10 minutes ». It ties to an SLO: if the affected service carries an availability objective, these events foreshadow error-budget burn. The alert should point to a runbook, not just quote the message.

Best practices

  • Do not build your only critical alert on an event: the documentation calls them best-effort.
  • Pair events with state metrics (pods not ready, restarts) to catch the outage even if an event is missing.
  • Keep Warning events longer than Normal ones.
  • Enable storage and test a Collector restart.
  • Limit namespaces and measure volume before widening.
  • Record the receiver as alpha in your risk register.

Frequently asked questions

How long does Kubernetes keep events?

The default of kube-apiserver’s --event-ttl option is one hour, according to its documentation. A managed cluster provider may apply something else: check its documentation.

Should I use the k8s_events receiver in production?

Its README rates it alpha for logs. It can suit complementary collection, but test it and watch for configuration changes before trusting it with something essential.

Can I open these events in Dynatrace?

This article covers open source tools only. If you send these logs to Dynatrace over OTLP, read docs.dynatrace.com and keep SaaS and Managed apart: I mix no platform feature in here.

Conclusion

Kubernetes events answer the « why » of an incident, but for one hour by default only. Read them by hand to set your policy, export them as logs with the Collector, deduplicate, then alert on a few recurring reasons. Sources: Event API reference, k8s_events receiver.

span.observer is an independent community blog, not affiliated with Dynatrace LLC. Kubernetes and OpenTelemetry belong to their owners. Tools change quickly: check commands and options in the official documentation.


Originally published on span.observer. French version: https://span.observer/fr/evenements-kubernetes-lire-conserver-alerter/.

Top comments (0)