Skip to content

Commit 6e8ea64

Browse files
author
Bob Furu
authored
Merge pull request #23408 from rh-max/monitoring-timeseries-metadata
Monitoring timeseries metadata
2 parents 54b2596 + b5f23f9 commit 6e8ea64

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * monitoring/cluster_monitoring/configuring-the-monitoring-stack.adoc
4+
5+
[id="attaching-additional-labels-to-your-time-series-and-alerts_{context}"]
6+
= Attaching additional labels to your time series and alerts
7+
8+
Using the external labels feature of Prometheus, you can attach additional custom labels to all time series and alerts leaving the Prometheus cluster.
9+
10+
.Prerequisites
11+
12+
* Make sure you have the `cluster-monitoring-config` ConfigMap object with the `data/config.yaml` section.
13+
14+
.Procedure
15+
16+
. Start editing the `cluster-monitoring-config` ConfigMap:
17+
+
18+
----
19+
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
20+
----
21+
22+
. Define a map of labels you want to add for every metric under `data/config.yaml`:
23+
+
24+
[source, yaml]
25+
----
26+
apiVersion: v1
27+
kind: ConfigMap
28+
metadata:
29+
name: cluster-monitoring-config
30+
namespace: openshift-monitoring
31+
data:
32+
config.yaml: |
33+
prometheusK8s:
34+
externalLabels:
35+
<key>: <value> <1>
36+
----
37+
+
38+
<1> Substitute `<key>: <value>` with a map of key-value pairs where `<key>` is a unique name of the new label and `<value>` is its value.
39+
+
40+
[WARNING]
41+
====
42+
Do not use `prometheus` or `prometheus_replica` as key names, because they are reserved and would be overwritten.
43+
====
44+
+
45+
For example, to add metadata about the region and environment to all time series and alerts, use:
46+
+
47+
[source, yaml]
48+
----
49+
apiVersion: v1
50+
kind: ConfigMap
51+
metadata:
52+
name: cluster-monitoring-config
53+
namespace: openshift-monitoring
54+
data:
55+
config.yaml: |
56+
prometheusK8s:
57+
externalLabels:
58+
region: eu
59+
environment: prod
60+
----
61+
62+
. Save the file to apply the changes. The new configuration is applied automatically.

monitoring/cluster_monitoring/configuring-the-monitoring-stack.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ include::modules/monitoring-listing-acting-alerting-rules.adoc[leveloffset=+2]
7676

7777
* See also link:https://prometheus.io/docs/alerting/alertmanager/[the Alertmanager documentation].
7878

79+
include::modules/monitoring-attaching-additional-labels-to-your-time-series-and-alerts.adoc[leveloffset=+1]
80+
7981
.Next steps
8082

8183
* xref:../../monitoring/cluster_monitoring/managing-cluster-alerts.adoc#managing-cluster-alerts[Manage cluster alerts.]

0 commit comments

Comments
 (0)