Skip to content

Commit

Permalink
Merge pull request openshift#73192 from bburt-rh/OBSDOCS-400-update-C…
Browse files Browse the repository at this point in the history
…LI-command-for-getting-federation-host-for-monitoring

OBSDOCS-400: update-CLI-command-for-getting-federation-host-for-monitoring
  • Loading branch information
bburt-rh authored Mar 18, 2024
2 parents 53ea37c + 62e4caf commit 597dee2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[id="monitoring-querying-metrics-by-using-the-federation-endpoint-for-prometheus_{context}"]
= Querying metrics by using the federation endpoint for Prometheus

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

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

* You have installed the OpenShift CLI (`oc`).
* You have obtained the host URL for the {product-title} route.
* 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.
+
[NOTE]
====
You can only use bearer token authentication to access the federation endpoint.
You can only use bearer token authentication to access the Prometheus federation endpoint.
====
* You are logged in to an account that has permission to get the Prometheus federation route.
+
[NOTE]
====
If your account does not have permission to get the Prometheus federation route, a cluster administrator can provide the URL for the route.
====
.Procedure

. Retrieve the bearer token:
. Retrieve the bearer token by running the following the command:
+
[source,terminal]
----
$ TOKEN=`oc whoami -t`
$ TOKEN=$(oc whoami -t)
----

. Query metrics from the `/federate` route.
The following example queries `up` metrics:
. Get the Prometheus federation route URL by running the following command:
+
[source,terminal]
----
$ curl -G -s -k -H "Authorization: Bearer $TOKEN" \
'https://<federation_host>/federate' \ <1>
--data-urlencode 'match[]=up'
$ HOST=$(oc -n openshift-monitoring get route prometheus-k8s-federate -ojsonpath={.spec.host})
----

. Query metrics from the `/federate` route.
The following example command queries `up` metrics:
+
<1> For <federation_host>, substitute the host URL for the federation route.
[source,terminal]
----
$ curl -G -k -H "Authorization: Bearer $TOKEN" https://$HOST/federate --data-urlencode 'match[]=up'
----
+
.Example output
+
Expand Down
12 changes: 4 additions & 8 deletions monitoring/accessing-third-party-monitoring-apis.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,16 @@ include::modules/monitoring-accessing-third-party-monitoring-web-service-apis.ad
// Querying metrics by using the federation endpoint for Prometheus
include::modules/monitoring-querying-metrics-by-using-the-federation-endpoint-for-prometheus.adoc[leveloffset=+1]

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

ifndef::openshift-dedicated,openshift-rosa[]
[role="_additional-resources"]
.Additional resources
* 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]
endif::openshift-dedicated,openshift-rosa[]
[role="_additional-resources"]
[id="additional-resources_accessing-third-party-monitoring-apis"]
== Additional resources

ifndef::openshift-dedicated,openshift-rosa[]
* 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]
endif::openshift-dedicated,openshift-rosa[]
* xref:../monitoring/configuring-the-monitoring-stack.adoc#configuring_remote_write_storage_configuring-the-monitoring-stack[Configuring remote write storage]
* xref:../monitoring/managing-metrics.adoc#managing-metrics[Managing metrics]
* xref:../monitoring/managing-alerts.adoc#managing-alerts[Managing alerts]

0 comments on commit 597dee2

Please sign in to comment.