This is a cache of https://docs.okd.io/latest/observability/monitoring/accessing-metrics/accessing-metrics-as-an-administrator.html. It is a snapshot of the page at 2025-02-18T19:09:46.750+0000.
Accessing metrics as an administrator - Monitoring | Observability | OKD 4
×

Viewing a list of available metrics

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.

Prerequisites
  • 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 OKD CLI (oc).

  • You have obtained the OKD 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.

Procedure
  1. If you have not obtained the OKD API route for Thanos Querier, run the following command:

    $ oc get routes -n openshift-monitoring thanos-querier -o jsonpath='{.status.ingress[0].host}'
  2. 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 OKD API route for Thanos Querier.

Querying metrics for all projects with the OKD web console

You can use the OKD 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 OKD and user-defined projects in the Metrics UI.

The Metrics UI includes predefined queries, for example, CPU, memory, bandwidth, or network packet for all projects. You can also run custom Prometheus Query Language (PromQL) queries.

Prerequisites
  • 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).

Procedure
  1. In the Administrator perspective of the OKD web console, click Observe and go to the Metrics tab.

  2. To add one or more queries, perform any of the following actions:

    Option Description

    Select an existing query.

    From the Select query drop-down list, select an existing query.

    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. Use the keyboard arrows to select one of these suggested items and then press Enter to add the item to your expression. Move your mouse pointer over a suggested item to view a brief description of that item.

    Add multiple queries.

    Click Add query.

    Duplicate an existing query.

    Click the options menu kebab next to the query, then choose Duplicate query.

    Disable a query from being run.

    Click the options menu kebab next to the query and choose Disable query.

  3. To run queries that you created, click Run queries. The metrics from the queries are visualized on the plot. If a query is invalid, the UI shows an error message.

    • When drawing time series graphs, queries that operate on large amounts of data might time out or overload the browser. To avoid this, click Hide graph and calibrate your query by 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. Click the ˅ down arrowhead to minimize the expanded view for a query.

  4. Optional: Save the page URL to use this set of queries again in the future.

  5. Explore the visualized metrics. Initially, all metrics from all enabled queries are shown on the plot. Select which metrics are shown by performing any of the following actions:

    Option Description

    Hide all metrics from a query.

    Click the options menu kebab for the query and click Hide all series.

    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.

    Perform one of the following actions:

    • Visually select the time range by clicking and dragging on the plot horizontally.

    • Use the menu to select the time range.

    Reset the time range.

    Click Reset zoom.

    Display outputs for all queries at a specific point in time.

    Hover over the plot at the point you are interested in. The query outputs appear in a pop-up box.

    Hide the plot.

    Click Hide graph.

Additional resources

Getting detailed information about a metrics target

You can use the OKD 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 OKD monitoring is not able to scrape metrics from a targeted component.

The Metrics targets page shows targets for default OKD projects and for user-defined projects.

Prerequisites
  • You have access to the cluster as an administrator for the project for which you want to view metrics targets.

Procedure
  1. In the Administrator perspective of the OKD web console, go to ObserveTargets. 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 OKD 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

  2. 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:

    • Status filters:

      • Up. The target is currently up and being actively scraped for metrics.

      • Down. The target is currently down and not being scraped for metrics.

    • Source filters:

      • Platform. Platform-level targets relate only to default Red Hat OpenShift Service on AWS projects. These projects provide core Red Hat OpenShift Service on AWS functionality.

      • User. User targets relate to user-defined projects. These projects are user-created and can be customized.

    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.

  3. 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

Reviewing monitoring dashboards as a cluster administrator

In the Administrator perspective, you can view dashboards relating to core OKD cluster components.

Prerequisites
  • You have access to the cluster as a user with the cluster-admin cluster role.

Procedure
  1. In the Administrator perspective of the OKD web console, go to ObserveDashboards.

  2. Choose a dashboard in the Dashboard list. Some dashboards, such as etcd and Prometheus dashboards, produce additional sub-menus when selected.

  3. 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.

      1. Input or select the From and To dates and times.

      2. Click Save to save the custom time range.

  4. Optional: Select a Refresh Interval.

  5. Hover over each of the graphs within a dashboard to display detailed information about specific items.

Additional resources