@@ -18,12 +18,47 @@ endpoint.
18
18
19
19
.Procedure
20
20
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
+ ----
23
50
24
51
*Metrics query*
25
52
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:
27
62
+
28
63
[source,terminal]
29
64
----
@@ -55,45 +90,4 @@ imageregistry_http_request_duration_seconds{method="get",quantile="0.9"} 0.01484
55
90
imageregistry_http_request_duration_seconds{method="get",quantile="0.99"} 0.015981195
56
91
imageregistry_http_request_duration_seconds_sum{method="get"} 12.260727916000022
57
92
----
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