Lesson 3 / 25

The Data Model

Metric names, labels and samples.

A series is a name plus labels

Every time series is identified by a metric name and a set of labels (key-value pairs), for example http_requests_total{method="GET", route="/api/orders", status="200"}. Each sample is a float value with a timestamp. Prometheus adds target labels such as job and instance at scrape time. Each unique combination of label values is a separate series, which is why labels must have a limited set of values. The exposition format is plain text.

What a /metrics endpoint returns

The text exposition format (illustrative values).

# HELP http_requests_total Total HTTP requests handled.
# TYPE http_requests_total counter
http_requests_total{method="GET",route="/api/orders",status="200"} 10432
http_requests_total{method="GET",route="/api/orders",status="500"} 17
http_requests_total{method="POST",route="/api/orders",status="201"} 2210
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 5.2346e+07

Follow naming conventions

Use snake_case, a unit suffix (_seconds, _bytes) and _total for counters, as the Prometheus naming guide recommends.

Quick check: What identifies a unique time series in Prometheus?

  • The value
  • The metric name only
  • The scrape timestamp
  • The metric name together with its full set of label values
Answer

The metric name together with its full set of label values — Each label combination is a series.