Skip to content

Commit 597dee2

Browse files
authored
Merge pull request #73192 from bburt-rh/OBSDOCS-400-update-CLI-command-for-getting-federation-host-for-monitoring
OBSDOCS-400: update-CLI-command-for-getting-federation-host-for-monitoring
2 parents 53ea37c + 62e4caf commit 597dee2

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

modules/monitoring-querying-metrics-by-using-the-federation-endpoint-for-prometheus.adoc

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[id="monitoring-querying-metrics-by-using-the-federation-endpoint-for-prometheus_{context}"]
77
= Querying metrics by using the federation endpoint for Prometheus
88

9-
You can use the federation endpoint to scrape platform and user-defined metrics from a network location outside the cluster.
9+
You can use the federation endpoint for Prometheus to scrape platform and user-defined metrics from a network location outside the cluster.
1010
To do so, access the Prometheus `/federate` endpoint for the cluster via an {product-title} route.
1111

1212
[IMPORTANT]
@@ -17,11 +17,11 @@ This delay can affect the accuracy and timeliness of the scraped metrics.
1717
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.
1818
To avoid these issues, follow these recommendations:
1919
20-
* Do not try to retrieve all metrics data via the federation endpoint.
20+
* Do not try to retrieve all metrics data via the federation endpoint for Prometheus.
2121
Query it only when you want to retrieve a limited, aggregated data set.
2222
For example, retrieving fewer than 1,000 samples for each request helps minimize the risk of performance degradation.
2323
24-
* Avoid querying the federation endpoint frequently.
24+
* Avoid frequent querying of the federation endpoint for Prometheus.
2525
Limit queries to a maximum of one every 30 seconds.
2626
2727
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.
@@ -30,34 +30,43 @@ If you need to forward large amounts of data outside the cluster, use remote wri
3030
.Prerequisites
3131

3232
* You have installed the OpenShift CLI (`oc`).
33-
* You have obtained the host URL for the {product-title} route.
3433
* You have access to the cluster as a user with the `cluster-monitoring-view` cluster role or have obtained a bearer token with `get` permission on the `namespaces` resource.
3534
+
3635
[NOTE]
3736
====
38-
You can only use bearer token authentication to access the federation endpoint.
37+
You can only use bearer token authentication to access the Prometheus federation endpoint.
38+
====
39+
40+
* You are logged in to an account that has permission to get the Prometheus federation route.
41+
+
42+
[NOTE]
43+
====
44+
If your account does not have permission to get the Prometheus federation route, a cluster administrator can provide the URL for the route.
3945
====
4046
4147
.Procedure
4248

43-
. Retrieve the bearer token:
49+
. Retrieve the bearer token by running the following the command:
4450
+
4551
[source,terminal]
4652
----
47-
$ TOKEN=`oc whoami -t`
53+
$ TOKEN=$(oc whoami -t)
4854
----
4955

50-
. Query metrics from the `/federate` route.
51-
The following example queries `up` metrics:
56+
. Get the Prometheus federation route URL by running the following command:
5257
+
5358
[source,terminal]
5459
----
55-
$ curl -G -s -k -H "Authorization: Bearer $TOKEN" \
56-
'https://<federation_host>/federate' \ <1>
57-
--data-urlencode 'match[]=up'
60+
$ HOST=$(oc -n openshift-monitoring get route prometheus-k8s-federate -ojsonpath={.spec.host})
5861
----
62+
63+
. Query metrics from the `/federate` route.
64+
The following example command queries `up` metrics:
5965
+
60-
<1> For <federation_host>, substitute the host URL for the federation route.
66+
[source,terminal]
67+
----
68+
$ curl -G -k -H "Authorization: Bearer $TOKEN" https://$HOST/federate --data-urlencode 'match[]=up'
69+
----
6170
+
6271
.Example output
6372
+

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@ include::modules/monitoring-accessing-third-party-monitoring-web-service-apis.ad
2626
// Querying metrics by using the federation endpoint for Prometheus
2727
include::modules/monitoring-querying-metrics-by-using-the-federation-endpoint-for-prometheus.adoc[leveloffset=+1]
2828

29-
// Accessing metrics from outside the cluster for custom applications
29+
// Accessing metrics from outside the cluster for custom applications
3030
include::modules/accessing-metrics-outside-cluster.adoc[leveloffset=+1]
3131

32-
ifndef::openshift-dedicated,openshift-rosa[]
33-
[role="_additional-resources"]
34-
.Additional resources
35-
36-
* xref:../monitoring/enabling-monitoring-for-user-defined-projects.adoc#enabling-monitoring-for-user-defined-projects_enabling-monitoring-for-user-defined-projects[Enabling monitoring for user-defined projects]
37-
endif::openshift-dedicated,openshift-rosa[]
38-
3932
[role="_additional-resources"]
4033
[id="additional-resources_accessing-third-party-monitoring-apis"]
4134
== Additional resources
4235

36+
ifndef::openshift-dedicated,openshift-rosa[]
37+
* xref:../monitoring/enabling-monitoring-for-user-defined-projects.adoc#enabling-monitoring-for-user-defined-projects_enabling-monitoring-for-user-defined-projects[Enabling monitoring for user-defined projects]
38+
endif::openshift-dedicated,openshift-rosa[]
4339
* xref:../monitoring/configuring-the-monitoring-stack.adoc#configuring_remote_write_storage_configuring-the-monitoring-stack[Configuring remote write storage]
4440
* xref:../monitoring/managing-metrics.adoc#managing-metrics[Managing metrics]
4541
* xref:../monitoring/managing-alerts.adoc#managing-alerts[Managing alerts]

0 commit comments

Comments
 (0)