AI Hints
Home›Kubernetes Tutorial›Observability
Kubernetes · Lesson 54 of 86

Events and Alerts

Dashboards and good alerts.

⏱ 2 min read▶ Video at 2:12:43🎓 Free
Watch this lesson in the Kubernetes courseWatch on YouTube ↗Full Kubernetes course

There are two more things to know. First, Kubernetes keeps a diary of what it does, the events. Second, watching numbers all day is impossible, so we need alerts that tap us on the shoulder. But bad alerts are worse than none. In this lesson, you will use events, and learn how to design alerts people trust.

Events and Alerts
From the video: Events and Alerts
  • Events: Kubernetes' diary
  • Dashboards for looking
  • Alerts for acting

The events diary

Events are objects, created by Kubernetes components, every time something happens. A pod was scheduled. An image was pulled. A container was killed. Let's create some trouble, and then ask for the recent events, sorted by time. We see a story, scheduled, pulling image, failed, back off. Events only live for about an hour, so check them early, or send them to your log store.

kubectl
kubectl run broken --image=nginx:no-such-tag
pod/broken created
kubectl get events --sort-by=.lastTimestamp | tail -5 | cut -c1-120
10s         Normal    Pulling                        pod/broken                          Pulling image "nginx:no-such-ta
8s          Warning   Failed                         pod/broken                          Failed to pull image "nginx:no-
8s          Warning   Failed                         pod/broken                          Error: ErrImagePull
8s          Normal    BackOff                        pod/broken                          Back-off pulling image "nginx:n
8s          Warning   Failed                         pod/broken                          Error: ImagePullBackOff

The golden signals

What should you watch? Google's engineers suggest four golden signals. Latency, how long requests take. Traffic, how many requests arrive. Errors, how many fail. And saturation, how full your resources are. If you track these four for each service, you will catch most problems. Dashboards, built in a tool like Grafana, put them on a single screen, so anyone can see the health of the system at a glance.

Latencyhow long requests take
Traffichow many requests
Errorshow many fail
Saturationhow full resources are

Good alerts and bad alerts

Now, alerts. A good alert is urgent, someone must act now. It is actionable, there is something to do. And it is about symptoms users feel, such as errors, and slow responses. A bad alert fires for every small blip, or for causes that nobody can fix at night, like a busy processor for one minute. Too many bad alerts cause alert fatigue, and people start ignoring all of them. Page people only for problems that hurt users, and send everything else to a dashboard, or a ticket.

Good alert

  • Urgent: needs action now
  • Actionable: a clear next step
  • About user-visible symptoms
  • Linked to a runbook

Bad alert

  • Fires on every blip
  • Nobody can act on it
  • About internal causes only
  • Causes alert fatigue

Summary

Excellent. Events record what Kubernetes did, the golden signals tell you what to watch, and good alerts are urgent, actionable, and about users. Observability is complete. Next, we look after the cluster itself, upgrades, backups, and maintenance.

Key takeaways
  • Events: short-lived diary
  • Latency, traffic, errors, saturation
  • Alert on user pain only
Next up: Cluster Operations — upgrades and backups