Accessing third-party monitoring APIs
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.
The following example commands show how to query the service API receivers for Alertmanager. This example requires that the associated user account be bound against the role in the openshift-monitoring
namespace and that the account has the privilege to view the route. This access only supports using a Bearer Token for authentication.
$ host=$(oc -n openshift-monitoring get route alertmanager-main -ojsonpath={.spec.host})
$ curl -H "Authorization: Bearer $token" -k "https://$host/api/v2/receivers"
You can use the federation endpoint 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 OKD route.
Prerequisites
You have installed the OpenShift CLI (
oc
).You have obtained the host URL for the OKD route.
You have access to the cluster as a user with the
cluster-monitoring-view
role or have obtained a bearer token withget
permission on the resource.
Procedure
Retrieve the bearer token: