🎓 A1Learner
🔍
0 of 50 lessons completed

Prometheus: Metrics, Logs and Traces

Observability rests on three kinds of evidence: metrics, logs and traces. Each one answers a different question about a system.

A metric

A metric is a number with a time. It is small, cheap to keep, and easy to graph.

http_requests_total 41
shopsentry_up 1

A log line

A log line records one event in words. It is rich in detail but heavy to search.

10:04:12 order 518 failed: card declined

A trace in one line

A trace follows one request across services. It shows where the seconds went.

checkout: web 40ms -> payment 820ms -> stock 15ms

Example

curl -s http://127.0.0.1:18101/metrics | grep -E '^(http_requests_total|shopsentry_up)'

Key points

  • Metrics: numbers measured over time, like requests per minute or free disk space.
  • Logs: written lines that record single events, like one failed login at 10:04.
  • Traces: the path of one request as it travels through each part of a system.
  • Metrics answer how much and how often, logs answer what happened, and traces answer where time went.
  • A metric shows a problem starting, a log often names the cause, and a trace shows the slow step.

In this example, ShopSentry reports four request counts and one health number. The counts are metrics: numbers that grow over time and can be graphed. The same page holds no log lines and no trace, so a log would be needed to learn why any single request failed.

Note

This course teaches metrics, not logs or traces.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Rust Playground

Exercise

Which kind of evidence best answers "how many orders failed in the last hour"?