You can use the dedicated API provided by Managed Service for Prometheus to view the monitoring data of Managed Service for Prometheus in a local Grafana system. This topic describes how to import data from Managed Service for Prometheus to a local Grafana system.

Prerequisites

  • Grafana is installed on your on-premises machine. For more information.

Step 1: Obtain the dedicated API provided by Managed Service for Prometheus

The dedicated API connects Managed Service for Prometheus to the local Grafana system. To obtain the API, perform the following steps:

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose Prometheus Service > Prometheus Instances.
  3. Find the Prometheus instance and click Settings in the Actions column.
  4. On the Settings tab, copy a public HTTP API address or a private HTTP API address based on your business requirements.
    Note If you want to import data from a Prometheus instance for cloud services, copy an HTTP API address based on the cloud service.
    pg_pm_settings_tab_agent_settings
  5. Optional:Click Generate Token in the upper part of the tab to obtain the authentication token of the Prometheus instance. This way, you can transfer data from the Prometheus instance to your Grafana system with higher security.
    Important After the authentication token is generated, you must specify the token when you add the Prometheus instance to your Grafana system as a data source. Otherwise, monitoring data cannot be read from the Managed Service for Prometheus.
    Copy a token

Step 2: Add a data source to the local Grafana system

To add the API obtained in Step 1 as the data source of the local Grafana system, perform the following steps:

  1. Log on to the local Grafana system as an administrator.
  2. In the left-side navigation pane, choose Configuration > Data sources.
    Note This menu is visible only to the administrator.
  3. On the Data sources tab, click Add data source.
  4. On the Add data source page, click Prometheus.
  5. On the Settings tab, enter a name in the Name field and copy the Step 1: Obtain the dedicated API provided by Managed Service for Prometheus HTTP API address to the URL field.
  6. Optional:In the Custom HTTP Headers section, click Add header and set the Header parameter to Authorization and the Value parameter to the authentication token that you obtained in Step 1: Obtain the dedicated API provided by Managed Service for Prometheus.
    tab_settings
  7. Click Save & test.

Verify the results

Perform the following steps to check whether the data source is added:

  1. Log on to the local Grafana system.
  2. In the left-side navigation pane, choose + > Create.
  3. On the New dashboard page, click Add an empty panel.
  4. On the Query tab of the New dashboard/Edit Panel page, select the data source added in Step 2 from the drop-down list. In the Metrics field of the A section, enter a metric name and press Enter.
    If a chart is displayed for the metric, the data source is added. Otherwise, check whether the HTTP API address or the authentication token that you entered is valid and whether the data source contains the monitoring data of Managed Service for Prometheus. pg_explore_with_metrics