Skip to content

Commit 0d9027c

Browse files
authored
Merge pull request #72877 from bburt-rh/OBSDOCS-900-expand-revise-monitoring-API-access-section
OBSDOCS-900: expand and revise monitoring API access section
2 parents c41c9cb + 6c4bce5 commit 0d9027c

5 files changed

+69
-23
lines changed

modules/accessing-metrics-outside-cluster.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[id="accessing-metrics-from-outside-cluster_{context}"]
77
= Accessing metrics from outside the cluster for custom applications
88

9-
Learn how to query Prometheus statistics from the command line when monitoring your own services. You can access monitoring data from outside the cluster with the `thanos-querier` route.
9+
You can query Prometheus metrics from outside the cluster when monitoring your own services with user-defined projects. Access this data from outside the cluster by using the `thanos-querier` route.
1010

1111
This access only supports using a Bearer Token for authentication.
1212

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * monitoring/accessing-third-party-monitoring-uis-and-apis.adoc
4+
5+
:_mod-docs-content-type: CONCEPT
6+
[id="about-accessing-monitoring-web-service-apis_{context}"]
7+
= About accessing monitoring web service APIs
8+
9+
You can directly access web service API endpoints from the command line for the following monitoring stack components:
10+
11+
* Prometheus
12+
* Alertmanager
13+
* Thanos Ruler
14+
* Thanos Querier
15+
16+
[NOTE]
17+
====
18+
To access Thanos Ruler and Thanos Querier service APIs, the requesting account must have `get` permission on the namespaces resource, which can be granted by binding the `cluster-monitoring-view` cluster role to the account.
19+
====
20+
21+
Accessing web service APIs only supports using a Bearer Token for authentication.

modules/monitoring-accessing-third-party-monitoring-web-service-apis.adoc

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,41 @@
33
// * monitoring/accessing-third-party-monitoring-uis-and-apis.adoc
44

55
:_mod-docs-content-type: PROCEDURE
6-
[id="accessing-third-party-monitoring-web-service-apis_{context}"]
7-
= Accessing third-party monitoring web service APIs
6+
[id="accessing-a-monitoring-web-service-api_{context}"]
7+
= Accessing a monitoring web service API
88

9-
[role="_abstract"]
10-
You can directly access third-party web service APIs from the command line for the following monitoring stack components: Prometheus, Alertmanager, Thanos Ruler, and Thanos Querier.
9+
The following example shows how to query the service API receivers for the Alertmanager service used in core platform monitoring.
10+
You can use a similar method to access the `prometheus-k8s` service for core platform Prometheus and the `thanos-ruler` service for Thanos Ruler.
1111

12-
The following example commands show how to query the service API receivers for Alertmanager.
13-
This example requires that the associated user account be bound against the `monitoring-alertmanager-edit` role in the `openshift-monitoring` namespace and that the account has the privilege to view the route.
14-
This access only supports using a Bearer Token for authentication.
12+
.Prerequisites
1513

16-
[source,terminal]
17-
----
18-
$ oc login -u <username> -p <password>
19-
----
14+
* You are logged in to an account that is bound against the `monitoring-alertmanager-edit` role in the `openshift-monitoring` namespace.
15+
* You are logged in to an account that has permission to get the Alertmanager API route.
16+
+
17+
[NOTE]
18+
====
19+
If your account does not have permission to get the Alertmanager API route, a cluster administrator can provide the URL for the route.
20+
====
21+
22+
.Procedure
2023

24+
. Extract an authentication token by running the following command:
25+
+
2126
[source,terminal]
2227
----
23-
$ host=$(oc -n openshift-monitoring get route alertmanager-main -ojsonpath={.spec.host})
28+
$ TOKEN=$(oc whoami -t)
2429
----
2530

31+
. Extract the `alertmanager-main` API route URL by running the following command:
32+
+
2633
[source,terminal]
2734
----
28-
$ token=$(oc whoami -t)
35+
$ HOST=$(oc -n openshift-monitoring get route alertmanager-main -ojsonpath={.spec.host})
2936
----
3037

38+
. Query the service API receivers for Alertmanager by running the following command:
39+
+
3140
[source,terminal]
3241
----
33-
$ curl -H "Authorization: Bearer $token" -k "https://$host/api/v2/receivers"
42+
$ curl -H "Authorization: Bearer $TOKEN" -k "https://$HOST/api/v2/receivers"
3443
----
35-
36-
[NOTE]
37-
====
38-
To access Thanos Ruler and Thanos Querier service APIs, the requesting account must have `get` permission on the namespaces resource, which can be done by granting the `cluster-monitoring-view` cluster role to the account.
39-
====

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
You can use the federation endpoint 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

12-
[WARNING]
12+
[IMPORTANT]
1313
====
1414
A delay in retrieving metrics data occurs when you use federation.
1515
This delay can affect the accuracy and timeliness of the scraped metrics.
@@ -44,15 +44,15 @@ You can only use bearer token authentication to access the federation endpoint.
4444
+
4545
[source,terminal]
4646
----
47-
$ token=`oc whoami -t`
47+
$ TOKEN=`oc whoami -t`
4848
----
4949

5050
. Query metrics from the `/federate` route.
5151
The following example queries `up` metrics:
5252
+
5353
[source,terminal]
5454
----
55-
$ curl -G -s -k -H "Authorization: Bearer $token" \
55+
$ curl -G -s -k -H "Authorization: Bearer $TOKEN" \
5656
'https://<federation_host>/federate' \ <1>
5757
--data-urlencode 'match[]=up'
5858
----

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,33 @@ toc::[]
99
[role="_abstract"]
1010
In {product-title} {product-version}, you can access web service APIs for some third-party monitoring components from the command line interface (CLI).
1111

12+
[IMPORTANT]
13+
====
14+
In certain situations, accessing API endpoints can degrade the performance and scalability of your cluster, especially if you use endpoints to retrieve, send, or query large amounts of metrics data.
15+
16+
To avoid these issues, follow these recommendations:
17+
18+
* Avoid querying endpoints frequently. Limit queries to a maximum of one every 30 seconds.
19+
* Do not try to retrieve all metrics data via the `/federate` 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.
20+
====
21+
1222
// Accessing service APIs for third-party monitoring components
23+
include::modules/monitoring-about-accessing-monitoring-web-service-apis.adoc[leveloffset=+1]
1324
include::modules/monitoring-accessing-third-party-monitoring-web-service-apis.adoc[leveloffset=+1]
1425

1526
// Querying metrics by using the federation endpoint for Prometheus
1627
include::modules/monitoring-querying-metrics-by-using-the-federation-endpoint-for-prometheus.adoc[leveloffset=+1]
1728

29+
// Accessing metrics from outside the cluster for custom applications
30+
include::modules/accessing-metrics-outside-cluster.adoc[leveloffset=+1]
31+
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+
1839
[role="_additional-resources"]
1940
[id="additional-resources_accessing-third-party-monitoring-apis"]
2041
== Additional resources

0 commit comments

Comments
 (0)