Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[id="attaching-additional-labels-to-your-time-series-and-alerts_{context}"]
= Attaching additional labels to your time series and alerts

Using the external labels feature of Prometheus, you can attach custom labels to all time series and alerts leaving Prometheus.
You can attach custom labels to all time series and alerts leaving Prometheus by using the external labels feature of Prometheus.

.Prerequisites

Expand Down Expand Up @@ -42,17 +42,19 @@ data:
config.yaml: |
prometheusK8s:
externalLabels:
<key>: <value> <1>
<key>: <value> # <1>
----
+
<1> Substitute `<key>: <value>` with a map of key-value pairs where `<key>` is a unique name for the new label and `<value>` is its value.
+
[WARNING]
====
Do not use `prometheus` or `prometheus_replica` as key names, because they are reserved and will be overwritten.
* Do not use `prometheus` or `prometheus_replica` as key names, because they are reserved and will be overwritten.

* Do not use `cluster` or `managed_cluster` as key names. Using them can cause issues where you are unable to see data in the developer dashboards.
====
+
For example, to add metadata about the region and environment to all time series and alerts, use:
For example, to add metadata about the region and environment to all time series and alerts, use the following example:
+
[source,yaml]
----
Expand Down Expand Up @@ -90,22 +92,24 @@ data:
config.yaml: |
prometheus:
externalLabels:
<key>: <value> <1>
<key>: <value> # <1>
----
+
<1> Substitute `<key>: <value>` with a map of key-value pairs where `<key>` is a unique name for the new label and `<value>` is its value.
+
[WARNING]
====
Do not use `prometheus` or `prometheus_replica` as key names, because they are reserved and will be overwritten.
* Do not use `prometheus` or `prometheus_replica` as key names, because they are reserved and will be overwritten.

* Do not use `cluster` or `managed_cluster` as key names. Using them can cause issues where you are unable to see data in the developer dashboards.
====
+
[NOTE]
====
In the `openshift-user-workload-monitoring` project, Prometheus handles metrics and Thanos Ruler handles alerting and recording rules. Setting `externalLabels` for `prometheus` in the `user-workload-monitoring-config` `ConfigMap` object will only configure external labels for metrics and not for any rules.
====
+
For example, to add metadata about the region and environment to all time series and alerts related to user-defined projects, use:
For example, to add metadata about the region and environment to all time series and alerts related to user-defined projects, use the following example:
+
[source,yaml]
----
Expand Down