Skip to content

Commit 7197c82

Browse files
authored
Merge pull request #56189 from subhtk/BZ1998450N
BZ#1998450: Updated procedure related to accessing registry metrics.
2 parents 8cc8297 + b38c6ba commit 7197c82

File tree

1 file changed

+39
-45
lines changed

1 file changed

+39
-45
lines changed

modules/registry-accessing-metrics.adoc

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,47 @@ endpoint.
1818

1919
.Procedure
2020

21-
There are two ways in which you can access the metrics, running a metrics query
22-
or using the cluster role.
21+
You can access the metrics by running a metrics query using a cluster role.
22+
23+
*Cluster role*
24+
25+
. Create a cluster role if you do not already have one to access the metrics:
26+
+
27+
[source,terminal]
28+
----
29+
$ cat <<EOF | oc create -f -
30+
apiVersion: rbac.authorization.k8s.io/v1
31+
kind: ClusterRole
32+
metadata:
33+
name: prometheus-scraper
34+
rules:
35+
- apiGroups:
36+
- image.openshift.io
37+
resources:
38+
- registry/metrics
39+
verbs:
40+
- get
41+
EOF
42+
----
43+
44+
. Add this role to a user, run the following command:
45+
+
46+
[source,terminal]
47+
----
48+
$ oc adm policy add-cluster-role-to-user prometheus-scraper <username>
49+
----
2350

2451
*Metrics query*
2552

26-
. Run a metrics query, for example:
53+
. Get the user token.
54+
+
55+
[source,terminal]
56+
----
57+
openshift:
58+
$ oc whoami -t
59+
----
60+
61+
. Run a metrics query in node or inside a pod, for example:
2762
+
2863
[source,terminal]
2964
----
@@ -55,45 +90,4 @@ imageregistry_http_request_duration_seconds{method="get",quantile="0.9"} 0.01484
5590
imageregistry_http_request_duration_seconds{method="get",quantile="0.99"} 0.015981195
5691
imageregistry_http_request_duration_seconds_sum{method="get"} 12.260727916000022
5792
----
58-
<1> `<user>` can be arbitrary, but `<secret>` must match the value specified in the
59-
registry configuration.
60-
61-
*Cluster role*
62-
63-
. Create a cluster role if you do not already have one to access the metrics:
64-
+
65-
[source,terminal]
66-
----
67-
$ cat <<EOF | oc create -f -
68-
apiVersion: rbac.authorization.k8s.io/v1
69-
kind: ClusterRole
70-
metadata:
71-
name: prometheus-scraper
72-
rules:
73-
- apiGroups:
74-
- image.openshift.io
75-
resources:
76-
- registry/metrics
77-
verbs:
78-
- get
79-
EOF
80-
----
81-
82-
. Add this role to a user, run the following command:
83-
+
84-
[source,terminal]
85-
----
86-
$ oc adm policy add-cluster-role-to-user prometheus-scraper <username>
87-
----
88-
89-
. Access the metrics using cluster role. The part of
90-
the configuration file responsible for metrics should look like this:
91-
+
92-
[source,yaml]
93-
----
94-
openshift:
95-
version: 1.0
96-
metrics:
97-
enabled: true
98-
...
99-
----
93+
<1> The `<user>` object can be arbitrary, but `<secret>` tag must use the user token.

0 commit comments

Comments
 (0)