Skip to content

Commit 1cb09cd

Browse files
committed
Split labels from naming.md into a new labels.md
Signed-off-by: Conall O'Brien <conall@conall.net>
1 parent e42cd96 commit 1cb09cd

2 files changed

Lines changed: 45 additions & 33 deletions

File tree

docs/practices/labels.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: Label Best Practices
3+
sort_rank: 1
4+
---
5+
6+
The label conventions presented in this document are not required
7+
for using Prometheus, but can serve as both a style-guide and a collection of
8+
best practices. Individual organizations may want to approach some of these
9+
practices, e.g. naming conventions, differently.
10+
11+
## Labels
12+
13+
Prometheus labels can come from both the target and from
14+
[relabeling in discovery](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) as well as from the target itself.
15+
16+
By default Prometheus configures two primary discovery target labels.
17+
18+
* `job`
19+
* The `job` label is one of the few ubiquitious labels, set at scrape time, and is
20+
used to identify metrics scraped from the same target/exporter.
21+
* If not specified in PromQL expressions, they will match unrelated metrics with the same name. This is especially true in a multi system or multi tenant installation
22+
23+
WARNING: When using `without`, be careful not to strip out the `job` label accidentally.
24+
25+
* `instance`
26+
* The `instance` label will include the `ip:port` what was scraped, providing a
27+
crucial breadcrumb for debugging scrape time issues
28+
29+
### General Labelling Advice
30+
31+
Use labels to differentiate the characteristics of the thing that is being measured:
32+
33+
* `api_http_requests_total` - differentiate request types: `operation="create|update|delete"`
34+
* `api_request_duration_seconds` - differentiate request stages: `stage="extract|transform|load"`
35+
36+
Do not put the label names in the metric name, as this introduces redundancy
37+
and will cause confusion if the respective labels are aggregated away.
38+
39+
CAUTION: Remember that every unique combination of key-value label
40+
pairs represents a new time series, which can dramatically increase the amount
41+
of data stored. Do not use labels to store dimensions with high cardinality
42+
(many different label values), such as user IDs, email addresses, or other
43+
unbounded sets of values.

docs/practices/naming.md

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: Metric and label naming
2+
title: Metric naming
33
sort_rank: 1
44
---
55

6-
The metric and label conventions presented in this document are not required
6+
The metric conventions presented in this document are not required
77
for using Prometheus, but can serve as both a style-guide and a collection of
88
best practices. Individual organizations may want to approach some of these
99
practices, e.g. naming conventions, differently.
@@ -80,37 +80,6 @@ the underlying metric type and unit you work with.
8080
* **Metric collisions**: With growing adoption and metric changes over time, there are cases where lack
8181
of unit and type information in the metric name will cause certain series to collide (e.g. `process_cpu` for seconds and milliseconds).
8282

83-
## Labels
84-
85-
Prometheus labels can come from both the target and from [relabeling in discovery](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) as well as from the target itself.
86-
87-
By default Prometheus configures two primary discovery target labels.
88-
89-
* `job`
90-
* The `job` label is one of the few ubiquitious labels, set at scrape time, and is used to identify metrics scraped from the same target/exporter.
91-
* If not specified in PromQL expressions, they will match unrelated metrics with the same name. This is especially true in a multi system or multi tenant installation
92-
93-
WARNING: When using `without`, be careful not to strip out the `job` label accidentally.
94-
95-
* `instance`
96-
* The `instance` label will include the `ip:port` what was scraped, providing a crucial breadcrumb for debugging scrape time issues
97-
98-
### General Labelling Advice
99-
100-
Use labels to differentiate the characteristics of the thing that is being measured:
101-
102-
* `api_http_requests_total` - differentiate request types: `operation="create|update|delete"`
103-
* `api_request_duration_seconds` - differentiate request stages: `stage="extract|transform|load"`
104-
105-
Do not put the label names in the metric name, as this introduces redundancy
106-
and will cause confusion if the respective labels are aggregated away.
107-
108-
CAUTION: Remember that every unique combination of key-value label
109-
pairs represents a new time series, which can dramatically increase the amount
110-
of data stored. Do not use labels to store dimensions with high cardinality
111-
(many different label values), such as user IDs, email addresses, or other
112-
unbounded sets of values.
113-
11483
## Base Units
11584

11685
Prometheus does not have any units hard coded. For better compatibility, base

0 commit comments

Comments
 (0)