Skip to content

Commit eca2a3e

Browse files
authored
Merge pull request #47335 from bburt-rh/RHDEVDOCS-3920-document-accessing-federation-endpoints-for-metrics
RHDEVDOCS-3920 - document querying the federate endpoint for Prometheus metrics
2 parents 587cdef + ebe6e28 commit eca2a3e

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * monitoring/accessing-third-party-monitoring-apis.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="monitoring-querying-metrics-by-using-the-federation-endpoint-for-prometheus_{context}"]
7+
= Querying metrics by using the federation endpoint for Prometheus
8+
9+
You can use the federation endpoint to scrape platform and user-defined metrics from a network location outside the cluster.
10+
To do so, access the Prometheus `/federate` endpoint for the cluster via an {product-title} route.
11+
12+
[WARNING]
13+
====
14+
A delay in retrieving metrics data occurs when you use federation.
15+
This delay can affect the accuracy and timeliness of the scraped metrics.
16+
17+
Using the federation endpoint can also degrade the performance and scalability of your cluster, especially if you use the federation endpoint to retrieve large amounts of metrics data.
18+
To avoid these issues, follow these recommendations:
19+
20+
* Do not try to retrieve all metrics data via the federation endpoint.
21+
Query it only when you want to retrieve a limited, aggregated data set.
22+
For example, retrieving fewer than 1,000 samples for each request helps minimize the risk of performance degradation.
23+
24+
* Avoid querying the federation endpoint frequently.
25+
Limit queries to a maximum of one every 30 seconds.
26+
27+
If you need to forward large amounts of data outside the cluster, use remote write instead. For more information, see the _Configuring remote write storage_ section.
28+
====
29+
30+
.Prerequisites
31+
32+
* You have installed the OpenShift CLI (`oc`).
33+
* You have obtained the host URL for the {product-title} route.
34+
* You have access to the cluster as a user with the `cluster-monitoring-view` role or have obtained a bearer token with `get` permission on the `namespaces` resource.
35+
+
36+
[NOTE]
37+
====
38+
You can only use bearer token authentication to access the federation endpoint.
39+
====
40+
41+
.Procedure
42+
43+
. Retrieve the bearer token:
44+
+
45+
[source,terminal]
46+
----
47+
$ token=`oc whoami -t`
48+
----
49+
50+
. Query metrics from the `/federate` route.
51+
The following example queries `up` metrics:
52+
+
53+
[source,terminal]
54+
----
55+
$ curl -G -s -k -H "Authorization: Bearer $token" \
56+
'https:/<federation_host>/federate' \ <1>
57+
--data-urlencode 'match[]=up'
58+
----
59+
+
60+
<1> For <federation_host>, substitute the host URL for the federation route.
61+
+
62+
.Example output
63+
+
64+
[source,terminal]
65+
----
66+
# TYPE up untyped
67+
up{apiserver="kube-apiserver",endpoint="https",instance="10.0.143.148:6443",job="apiserver",namespace="default",service="kubernetes",prometheus="openshift-monitoring/k8s",prometheus_replica="prometheus-k8s-0"} 1 1657035322214
68+
up{apiserver="kube-apiserver",endpoint="https",instance="10.0.148.166:6443",job="apiserver",namespace="default",service="kubernetes",prometheus="openshift-monitoring/k8s",prometheus_replica="prometheus-k8s-0"} 1 1657035338597
69+
up{apiserver="kube-apiserver",endpoint="https",instance="10.0.173.16:6443",job="apiserver",namespace="default",service="kubernetes",prometheus="openshift-monitoring/k8s",prometheus_replica="prometheus-k8s-0"} 1 1657035343834
70+
...
71+
----

monitoring/accessing-third-party-monitoring-apis.adoc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[id="accessing-third-party-monitoring-apis"]
33
= Accessing third-party monitoring APIs
44
include::_attributes/common-attributes.adoc[]
5-
:context: accessing-third-party-monitoring-uis-and-apis
5+
:context: accessing-third-party-monitoring-apis
66

77
toc::[]
88

@@ -12,10 +12,13 @@ In {product-title} {product-version}, you can access web service APIs for some t
1212
// Accessing service APIs for third-party monitoring components
1313
include::modules/monitoring-accessing-third-party-monitoring-web-service-apis.adoc[leveloffset=+1]
1414

15+
// Querying metrics by using the federation endpoint for Prometheus
16+
include::modules/monitoring-querying-metrics-by-using-the-federation-endpoint-for-prometheus.adoc[leveloffset=+1]
17+
1518
[role="_additional-resources"]
16-
[id="additional-resources_accessing-third-party-monitoring-uis-and-apis"]
19+
[id="additional-resources_accessing-third-party-monitoring-apis"]
1720
== Additional resources
1821

22+
* xref:../monitoring/configuring-the-monitoring-stack.adoc#configuring_remote_write_storage_configuring-the-monitoring-stack[Configuring remote write storage]
1923
* xref:../monitoring/managing-metrics.adoc#managing-metrics[Managing metrics]
2024
* xref:../monitoring/managing-alerts.adoc#managing-alerts[Managing alerts]
21-
* xref:../monitoring/reviewing-monitoring-dashboards.adoc#reviewing-monitoring-dashboards[Reviewing monitoring dashboards]

0 commit comments

Comments
 (0)