Skip to content

Commit 850b21a

Browse files
committed
OBSDOCS-1366: Add information about how to filter and keep metrics based on namespace
1 parent f920278 commit 850b21a

File tree

1 file changed

+50
-29
lines changed

1 file changed

+50
-29
lines changed

modules/monitoring-configuring-remote-write-storage.adoc

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ endif::openshift-dedicated,openshift-rosa[]
3636
ifdef::openshift-dedicated,openshift-rosa[]
3737
`openshift-user-workload-monitoring` namespace.
3838
endif::openshift-dedicated,openshift-rosa[]
39-
4039
+
4140
[WARNING]
4241
====
@@ -55,9 +54,7 @@ ifndef::openshift-dedicated,openshift-rosa[]
5554
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
5655
----
5756

58-
.. Add a `remoteWrite:` section under `data/config.yaml/prometheusK8s`.
59-
60-
.. Add an endpoint URL and authentication credentials in this section:
57+
.. Add a `remoteWrite:` section under `data/config.yaml/prometheusK8s`, as shown in the following example:
6158
+
6259
[source,yaml]
6360
----
@@ -70,10 +67,9 @@ data:
7067
config.yaml: |
7168
prometheusK8s:
7269
remoteWrite:
73-
- url: "https://remote-write-endpoint.example.com" <1>
74-
<endpoint_authentication_credentials> <2>
70+
- url: "https://remote-write-endpoint.example.com" #<1>
71+
<endpoint_authentication_credentials> #<2>
7572
----
76-
+
7773
<1> The URL of the remote write endpoint.
7874
<2> The authentication method and credentials for the endpoint.
7975
Currently supported authentication methods are AWS Signature Version 4, authentication using HTTP in an `Authorization` request header, Basic authentication, OAuth 2.0, and TLS client.
@@ -94,14 +90,12 @@ data:
9490
remoteWrite:
9591
- url: "https://remote-write-endpoint.example.com"
9692
<endpoint_authentication_credentials>
97-
<your_write_relabel_configs> <1>
93+
writeRelabelConfigs:
94+
- <your_write_relabel_configs> #<1>
9895
----
99-
<1> The write relabel configuration settings.
100-
+
101-
For `<your_write_relabel_configs>` substitute a list of write relabel configurations for metrics that you want to send to the remote endpoint.
102-
+
103-
The following sample shows how to forward a single metric called `my_metric`:
96+
<1> Add configuration for metrics that you want to send to the remote endpoint.
10497
+
98+
.Example of forwarding a single metric called `my_metric`
10599
[source,yaml]
106100
----
107101
apiVersion: v1
@@ -118,10 +112,26 @@ data:
118112
- sourceLabels: [__name__]
119113
regex: 'my_metric'
120114
action: keep
121-
122115
----
123116
+
124-
See the link:https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config[Prometheus relabel_config documentation] for information about write relabel configuration options.
117+
.Example of forwarding metrics called `my_metric_1` and `my_metric_2` in `my_namespace` namespace
118+
[source,yaml]
119+
----
120+
apiVersion: v1
121+
kind: ConfigMap
122+
metadata:
123+
name: cluster-monitoring-config
124+
namespace: openshift-monitoring
125+
data:
126+
config.yaml: |
127+
prometheusK8s:
128+
remoteWrite:
129+
- url: "https://remote-write-endpoint.example.com"
130+
writeRelabelConfigs:
131+
- sourceLabels: [__name__,namespace]
132+
regex: '(my_metric_1|my_metric_2);my_namespace'
133+
action: keep
134+
----
125135

126136
** *To configure remote write for the Prometheus instance that monitors user-defined projects*:
127137
endif::openshift-dedicated,openshift-rosa[]
@@ -132,9 +142,7 @@ endif::openshift-dedicated,openshift-rosa[]
132142
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
133143
----
134144

135-
.. Add a `remoteWrite:` section under `data/config.yaml/prometheus`.
136-
137-
.. Add an endpoint URL and authentication credentials in this section:
145+
.. Add a `remoteWrite:` section under `data/config.yaml/prometheus`, as shown in the following example:
138146
+
139147
[source,yaml]
140148
----
@@ -147,10 +155,9 @@ data:
147155
config.yaml: |
148156
prometheus:
149157
remoteWrite:
150-
- url: "https://remote-write-endpoint.example.com" <1>
151-
<endpoint_authentication_credentials> <2>
158+
- url: "https://remote-write-endpoint.example.com" #<1>
159+
<endpoint_authentication_credentials> #<2>
152160
----
153-
+
154161
<1> The URL of the remote write endpoint.
155162
<2> The authentication method and credentials for the endpoint.
156163
Currently supported authentication methods are AWS Signature Version 4, authentication using HTTP an `Authorization` request header, basic authentication, OAuth 2.0, and TLS client.
@@ -171,14 +178,12 @@ data:
171178
remoteWrite:
172179
- url: "https://remote-write-endpoint.example.com"
173180
<endpoint_authentication_credentials>
174-
<your_write_relabel_configs> <1>
181+
writeRelabelConfigs:
182+
- <your_write_relabel_configs> #<1>
175183
----
176-
<1> The write relabel configuration settings.
177-
+
178-
For `<your_write_relabel_configs>` substitute a list of write relabel configurations for metrics that you want to send to the remote endpoint.
179-
+
180-
The following sample shows how to forward a single metric called `my_metric`:
184+
<1> Add configuration for metrics that you want to send to the remote endpoint.
181185
+
186+
.Example of forwarding a single metric called `my_metric`
182187
[source,yaml]
183188
----
184189
apiVersion: v1
@@ -195,9 +200,25 @@ data:
195200
- sourceLabels: [__name__]
196201
regex: 'my_metric'
197202
action: keep
198-
199203
----
200204
+
201-
See the link:https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config[Prometheus relabel_config documentation] for information about write relabel configuration options.
205+
.Example of forwarding metrics called `my_metric_1` and `my_metric_2` in `my_namespace` namespace
206+
[source,yaml]
207+
----
208+
apiVersion: v1
209+
kind: ConfigMap
210+
metadata:
211+
name: user-workload-monitoring-config
212+
namespace: openshift-user-workload-monitoring
213+
data:
214+
config.yaml: |
215+
prometheus:
216+
remoteWrite:
217+
- url: "https://remote-write-endpoint.example.com"
218+
writeRelabelConfigs:
219+
- sourceLabels: [__name__,namespace]
220+
regex: '(my_metric_1|my_metric_2);my_namespace'
221+
action: keep
222+
----
202223

203224
. Save the file to apply the changes. The new configuration is applied automatically.

0 commit comments

Comments
 (0)