Prerequisites of a Monitoring System 00:00:01 From one process to a time series One service reports forty-five percent CPU. Its customers are starting to see errors. The dashboard has plenty of numbers, but which one would tell the on-call engineer that the service is failing its purpose? Each has a page with counters, gauges and histograms: CPU 45%, 120 requests a second. Every 15 to 60 seconds it visits each service. Each value gets its time. Good compression needs one or two bytes. PromQL calculates rates, sums and percentiles. Prometheus checks: CPU above 80% for ten minutes. It tells Alertmanager, which calls a person. Grafana asks Prometheus and draws. Record the measured quantity, units, labels and observation time. A monitoring backend can then distinguish a new sample for one existing series from an entirely new series. 00:01:00 Counters, gauges and distributions Total requests, errors, bytes. It only grows. Memory, queue length, open connections. How many took up to 0.1 s, 0.5 s and so on. The program gives a ready percentile. It cannot be joined with that of another server. A counter records cumulative events and may reset when a process restarts. A gauge records a current value. Histograms and summaries capture different information about distributions and have different aggregation limits. 00:01:34 Convert counter growth into rate Five samples of a request counter, one a minute, with a restart. 9,000 requests since the program started. That alone says little. 300 in a minute: 5 a second. 40 is smaller than 9,600. The program restarted, and 40 came since. From 40 to 340: 300 again. 300 plus 300 plus 40 plus 300 equals 940 in 240 seconds: 3.9 a second. Compare the increase over a time interval while accounting for resets. A raw counter that rose all day can belong to a very quiet service if the time window is long enough. 00:02:17 Scrape or send observations Two services and one collector, when all is well and when B dies. The collector visits both. The visit fails and the collector writes zero. Both send when they want. Also through a firewall. Dead, or nothing to say? The collector needs a rule: no word for five minutes. Pull-based collection can reveal that a target vanished from a regular scrape. Push can suit short-lived work, but freshness, duplication and target identity still require explicit handling. 00:02:50 The cost of one extra label GET, POST and three more. The pattern, not the path: 40 values. Six codes are common. Twenty servers. No store survives this. Put the user id into a log line. An unbounded label such as a customer identifier can create a time series for every distinct combination of labels. Use appropriate logs or traces for individual investigation and reserve metrics labels for bounded dimensions. 00:03:19 Give an alert a lifecycle The rule: CPU above 80% for ten minutes. 45%. The rule is false. 92%. The rule is true for the first time. A spike is no emergency. Still high after ten minutes. Alertmanager groups it with the same alert from another server and sends one message. 40%. The alert ends by itself. Define a sustained firing condition, an owner, a response and a recovery condition. Check that the signal clears after the actual customer experience improves, rather than after a monitoring process merely restarts. Choose signals for their question, define the aggregation window and alert on a customer-relevant condition. A graph that merely exists cannot tell anyone when or how to react.