Module 9 · Project 09 · Monitor It with Prometheus and Grafana · Lesson 31 of 48

Metrics and the golden signals

What to measure in a running system, how Prometheus collects it, and how to read the four golden signals on a dashboard.

In this lesson · about 30 minutes

  • Tell metrics, logs and traces apart
  • Name the four golden signals and what each one catches
  • Explain scraping, exporters and a few PromQL queries

You can't fix what you can't see

Your app is on Kubernetes, deployed by Git. Now: is it working? Are users waiting too long? Will the disk fill up tonight? Observability answers those questions with three kinds of data:

  • Metrics: numbers over time. Requests per second, error rate, memory used. Cheap to store, great for dashboards and alerts. This project.
  • Logs: text records of individual events. "Export job 5521 failed: S3 timeout." Great for finding out why. Project 10.
  • Traces: the path of one request through every service, with timings for each hop. Great for "which service is slow?" (OpenTelemetry, Jaeger, Tempo).

The four golden signals

If you can only watch four things about a service, watch these:

  1. Latency: how long requests take. Use percentiles: the p95 is the time 95% of requests beat. Averages hide the slow ones.
  2. Traffic: how much demand: requests per second.
  3. Errors: the share of requests that fail (HTTP 5xx, timeouts).
  4. Saturation: how full the system is: CPU, memory, disk, connection pools. It warns you before things break.

You'll also hear RED (Rate, Errors, Duration) for services and USE (Utilization, Saturation, Errors) for machines. Same idea.

How Prometheus works

Prometheus pulls (scrapes) metrics: every 15 seconds it fetches a plain-text page, usually /metrics, from each target and stores the numbers as time series.

# what the app exposes at /metrics
http_requests_total{method="GET", route="/notes", status="200"} 48213
http_requests_total{method="GET", route="/notes", status="500"} 37
http_request_duration_seconds_bucket{le="0.25"} 46102
process_resident_memory_bytes 1.31e+08
  • Your app exposes its own metrics with a client library (prom-client for Node, prometheus_client for Python).
  • Exporters expose metrics for things you didn't write: node_exporter for Linux machines, postgres_exporter, blackbox_exporter for "is this URL up?".
  • On Kubernetes, kube-prometheus-stack (a Helm chart) installs Prometheus, Grafana, Alertmanager, node_exporter and ready-made dashboards in one go.

A little PromQL

# traffic: requests per second over the last 5 minutes
sum(rate(http_requests_total[5m]))

# errors: percentage of 5xx responses
sum(rate(http_requests_total{status=~"5.."}[5m]))
  / sum(rate(http_requests_total[5m])) * 100

# latency: 95th percentile response time
histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))

rate() turns an ever-growing counter into "per second". sum by (...) adds series together. Grafana runs these queries and draws the answers as dashboard panels.

Try it · watch it run

Monitoring: golden signals and alerts

A live dashboard for the notes API. Cause each incident in turn and watch which signal moves first, and how the alert rules go from inactive to pending to firing. Switch back to normal and watch them resolve.

Cause an incident

each tick = 1 minute · min 0

Traffic

Requests per second

121

sum(rate(http_requests_total[5m]))

Latency

p95 response time (ms)

181

histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))

Errors

5xx error rate (%)

0.7%

sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) * 100

Saturation

Memory used (% of limit)

49%

container_memory_working_set_bytes / container_spec_memory_limit_bytes * 100

HighErrorRate

error rate > 5% for 3m

inactive

HighLatency

p95 latency > 500ms for 3m

inactive

MemoryAlmostFull

memory > 85% for 3m

inactive

alertmanager / events
prometheus: scraping notes-api:3000/metrics every 15s
Prometheus scrapes numbers from every app and stores them as time series; Grafana draws them; alert rules watch them. Each rule must stay true for 3 minutes before it fires, so a one-minute blip never wakes anyone up. Try the memory leak: memory is a slow-burning saturation signal that warns you before the crash.

Sorting drill

Which golden signal?

Sort each measurement into its signal.

  • p95 response time of /search
  • Requests per second to the API
  • Share of responses with status 500–599
  • Database connection pool 95% in use
  • Disk 88% full on the database node
  • Orders placed per minute
  • Requests that timed out

0 of 7 sorted

Check your understanding0 of 3 correct

Question 1

1.Why use the p95 latency instead of the average?

Question 2

2.How does Prometheus usually get metrics?

Question 3

3.What does node_exporter do?

Key terms

Say the meaning to yourself, then tap a card to check.

Quiz score: 0 of 3

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. The labs are simulations: no real servers are touched. When you build the projects yourself, use a practice virtual machine or a free-tier cloud account you control, watch your cloud spending, and never run cleanup or delete commands on a machine you care about. Tool names belong to their owners; versions and output are shown for learning and may differ slightly from yours. Read-aloud and the whiteboard voice use your device's built-in voices.