What are Prometheus labels?
Learn how labels identify time series, support filtering and aggregation, and affect cardinality, with examples of target and instrumentation labels.
Prometheus labels are named dimensions attached to a metric. In http_requests_total{method="GET", status="200"}, the labels distinguish successful GET requests from other combinations. A metric name together with its complete label set identifies one time series.
Filter and aggregate the same metric
Instead of encoding every combination into names such as requests_get_200, use one metric name and bounded labels:
http_requests_total{status="500"}
This selects server-error series. To calculate request rates by method:
sum by (method) (rate(http_requests_total[5m]))
The label model makes these slices explicit. Service discovery can add new target instances dynamically, provided the relevant discovery configuration already exists; labels themselves do not discover targets.
Understand cardinality
Each distinct metric-name and label-set combination is a separate series. A label with many possible values can multiply the number of stored series when combined with other dimensions.
Use labels such as method, status class, environment, or a normalized route when those dimensions answer an operational question. Avoid unbounded values such as individual user IDs, request IDs, or raw URLs containing unique parameters. They add series and churn without providing an efficient metrics query model for event-level investigation.
Where labels come from
| Label type | Source | Examples |
|---|---|---|
| Target labels | Scrape configuration and service discovery | job, instance, datacenter |
| Instrumentation labels | Application or exporter | method, status, route |
Target relabeling can transform discovery metadata before a scrape. Metric relabeling can transform selected sample labels before ingestion. If both sides supply the same label name, the scrape's honor_labels behavior determines how the conflict is handled.
FAQ
How do labels differ from alert annotations? Alert labels identify alert instances and support routing and grouping. Annotations carry explanatory text, descriptions, or runbook links. They do not become dimensions of the generated ALERTS series merely because they appear in a notification, although alert APIs can expose annotation content.
Can a label value change? A newly emitted sample with a different label set belongs to a different series. Relabeling does not rename the old stored samples. Keep identity labels stable when you want continuity in dashboards and alerts.
Sources
This guide is based on the documentation below; the examples have not been tested against a live deployment.
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan