$ oc get routes -n openshift-monitoring thanos-querier -o jsonpath='{.status.ingress[0].host}'
You can access metrics to monitor the performance of cluster components and your workloads.
As a cluster administrator or as a user with view permissions for all projects, you can view a list of metrics available in a cluster and output the list in JSON format.
You are a cluster administrator, or you have access to the cluster as a user with the cluster-monitoring-view
cluster role.
You have installed the OpenShift Container Platform CLI (oc
).
You have obtained the OpenShift Container Platform API route for Thanos Querier.
You are able to get a bearer token by using the oc whoami -t
command.
You can only use bearer token authentication to access the Thanos Querier API route. |
If you have not obtained the OpenShift Container Platform API route for Thanos Querier, run the following command:
$ oc get routes -n openshift-monitoring thanos-querier -o jsonpath='{.status.ingress[0].host}'
Retrieve a list of metrics in JSON format from the Thanos Querier API route by running the following command. This command uses oc
to authenticate with a bearer token.
$ curl -k -H "Authorization: Bearer $(oc whoami -t)" https://<thanos_querier_route>/api/v1/metadata (1)
1 | Replace <thanos_querier_route> with the OpenShift Container Platform API route for Thanos Querier. |
You can use the OpenShift Container Platform metrics query browser to run Prometheus Query Language (PromQL) queries to examine metrics visualized on a plot. This functionality provides information about the state of a cluster and any user-defined workloads that you are monitoring.
As a cluster administrator or as a user with view permissions for all projects, you can access metrics for all default OpenShift Container Platform and user-defined projects in the Metrics UI.
You have access to the cluster as a user with the cluster-admin
cluster role or with view permissions for all projects.
You have installed the OpenShift CLI (oc
).
From the Administrator perspective in the OpenShift Container Platform web console, select Observe → Metrics.
To add one or more queries, do any of the following:
Option | Description |
---|---|
Create a custom query. |
Add your Prometheus Query Language (PromQL) query to the Expression field. As you type a PromQL expression, autocomplete suggestions appear in a drop-down list. These suggestions include functions, metrics, labels, and time tokens. You can use the keyboard arrows to select one of these suggested items and then press Enter to add the item to your expression. You can also move your mouse pointer over a suggested item to view a brief description of that item. |
Add multiple queries. |
Select Add query. |
Duplicate an existing query. |
Select the Options menu |
Disable a query from being run. |
Select the Options menu |
To run queries that you created, select Run queries. The metrics from the queries are visualized on the plot. If a query is invalid, the UI shows an error message.
Queries that operate on large amounts of data might time out or overload the browser when drawing time series graphs. To avoid this, select Hide graph and calibrate your query using only the metrics table. Then, after finding a feasible query, enable the plot to draw the graphs. |
By default, the query table shows an expanded view that lists every metric and its current value. You can select ˅ to minimize the expanded view for a query. |
Optional: Save the page URL to use this set of queries again in the future.
Explore the visualized metrics. Initially, all metrics from all enabled queries are shown on the plot. You can select which metrics are shown by doing any of the following:
Option | Description |
---|---|
Hide all metrics from a query. |
Click the Options menu |
Hide a specific metric. |
Go to the query table and click the colored square near the metric name. |
Zoom into the plot and change the time range. |
Either:
|
Reset the time range. |
Select Reset zoom. |
Display outputs for all queries at a specific point in time. |
Hold the mouse cursor on the plot at that point. The query outputs will appear in a pop-up box. |
Hide the plot. |
Select Hide graph. |
Querying Prometheus (Prometheus documentation)
You can use the OpenShift Container Platform web console to view, search, and filter the endpoints that are currently targeted for scraping, which helps you to identify and troubleshoot problems. For example, you can view the current status of targeted endpoints to see when OpenShift Container Platform monitoring is not able to scrape metrics from a targeted component.
The Metrics targets page shows targets for default OpenShift Container Platform projects and for user-defined projects.
You have access to the cluster as an administrator for the project for which you want to view metrics targets.
In the Administrator perspective of the OpenShift Container Platform web console, go to Observe → Targets. The Metrics targets page opens with a list of all service endpoint targets that are being scraped for metrics.
This page shows details about targets for default OpenShift Container Platform and user-defined projects. This page lists the following information for each target:
Service endpoint URL being scraped
The ServiceMonitor
resource being monitored
The up or down status of the target
Namespace
Last scrape time
Duration of the last scrape
Optional: To find a specific target, perform any of the following actions:
Option | Description |
---|---|
Filter the targets by status and source. |
Choose filters in the Filter list. The following filtering options are available:
|
Search for a target by name or label. |
Enter a search term in the Text or Label field next to the search box. |
Sort the targets. |
Click one or more of the Endpoint Status, Namespace, Last Scrape, and Scrape Duration column headers. |
Click the URL in the Endpoint column for a target to go to its Target details page. This page provides information about the target, including the following information:
The endpoint URL being scraped for metrics
The current Up or Down status of the target
A link to the namespace
A link to the ServiceMonitor
resource details
Labels attached to the target
The most recent time that the target was scraped for metrics
In the Administrator perspective, you can view dashboards relating to core OpenShift Container Platform cluster components.
You have access to the cluster as a user with the cluster-admin
cluster role.
In the Administrator perspective in the OpenShift Container Platform web console, navigate to Observe → Dashboards.
Choose a dashboard in the Dashboard list. Some dashboards, such as etcd and Prometheus dashboards, produce additional sub-menus when selected.
Optional: Select a time range for the graphs in the Time Range list.
Select a pre-defined time period.
Set a custom time range by clicking Custom time range in the Time Range list.
Input or select the From and To dates and times.
Click Save to save the custom time range.
Optional: Select a Refresh Interval.
Hover over each of the graphs within a dashboard to display detailed information about specific items.