How do you monitor Kubernetes events?
BeginnerConceptKubernetes Monitoring, Scale & Cloud
Answer
Kubernetes events (FailedScheduling, BackOff, Unhealthy, FailedMount, Evicted) are stored in etcd with a short TTL (1 hour by default), so you must export them to keep them.
kubectl get events -A --sort-by=.lastTimestamp
kubectl get events -A --field-selector type=Warning
Ways to export:
- kubernetes-event-exporter to Loki, Elasticsearch, Slack or webhooks.
- OTel Collector
k8sobjectsreceiver (watchevents) ork8s_eventsreceiver. - Grafana Alloy
loki.source.kubernetes_events.
Once in Loki you can query {job="integrations/kubernetes/eventhandler"} |= "FailedScheduling" and build alerts. Events often explain why a metric changed.
More on Kubernetes Monitoring, Scale & Cloud
What is kube-prometheus-stack and what does it install?BeginnerWhat CRDs does the Prometheus Operator provide?IntermediateHow does the Prometheus Operator decide which ServiceMonitors to load?IntermediateWhich cAdvisor container memory metric should you watch, and why?IntermediateHow do metrics-server and the custom/external metrics APIs relate to HPA?IntermediateWhich kube-state-metrics metrics do you use most?Beginner