All Products
Search
Document Center

Managed Service for Prometheus:Integrate Prometheus monitoring data with a local Grafana system

Last Updated:Oct 09, 2024

If you want to view the data of Managed Service for Prometheus in your local Grafana system, you can use the API operations provided by Managed Service for Prometheus. This topic describes how to integrate the monitoring data of Managed Service for Prometheus with a local Grafana system.

Prerequisites

Grafana is installed on your on-premises machine.

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

The dedicated API can be used to integrate Managed Service for Prometheus with a local Grafana system. To obtain the API, perform the following steps:

  1. Log on to the Managed Service for Prometheus console.

  2. In the left-side navigation pane, click Instances.

  3. On the Instances page, click the Prometheus instance that you want to manage to go to the instance details page. On the Settings tab, copy the public or private URL of the HTTP API.

    Note

    If you use a Prometheus instance that monitors cloud services, select a URL of the HTTP API based on the monitored cloud service.

    pg_pm_settings_tab_agent_settings

  4. Optional. To improve data security for read and write operations, click Generate Token to obtain the token of the Prometheus instance.

    Important

    After the token is generated, you must configure the token when you add data sources in Grafana. Otherwise, you may fail to read data from Managed Service for Prometheus.

    复制Token

Step 2: Log on to the Grafana system

  1. Log on to the Managed Service for Grafana console. In the left-side navigation pane, click Workspace Management.

  2. On the Workspace Management page, find the workspace that you want to manage and click the URL in the URL column to go to Grafana.

    Note

    You can log on to Grafana with the administrator account of Grafana and the password that you configured when you created the workspace. You can also click Sign in with Alibaba Cloud to log on to Grafana with the current Alibaba Cloud account.

Step 3: Add a data source in the local Grafana system

Add the API obtained in Step 1 as a data source in the local Grafana system. Perform the following steps:

Grafana 9.x

  1. In the left-side navigation pane of Grafana, choose image > Add data source.

  2. On the Add data source page, click Prometheus.

  3. On the Settings tab, enter a name in the Name field and paste the API URL obtained in Step 1 in the URL field.

  4. Optional. In the Custom HTTP Headers section, click + Add header. Set the Header parameter to Authorization and the Value parameter to the token generated in Step 1.

    image

  5. Click Save & Test.

Grafana 10.x

  1. On the Grafana homepage, click the image icon.

  2. In the left-side navigation pane, choose Management > Data sources.

  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 paste the API URL obtained in Step 1 in the URL field.

  6. Optional. In the Custom HTTP Headers section, click + Add header. Set the Header parameter to Authorization and the Value parameter to the token generated in Step 1.

    image

  7. Click Save & Test.

Step 4: Create a dashboard

Grafana 9.x

  1. In the left-side navigation pane of Grafana, choose image > New dashboard.

  2. On the New dashboard page, click Add a new panel.

  3. On the Query tab of the Edit Panel page, select the data source added in Step 3 from the Data source drop-down list.

  4. In the A section of the Query tab, select a metric from the Metric and Labels drop-down lists, and then click Run queries.

    image

  5. In the right-side pane, specify the name, type, and graph styles of the chart.

  6. Click Apply.

  7. In the upper-right corner, click the 保存监控大盘 icon. Then, specify the name of the dashboard and the directory in which the dashboard resides.

  8. Click Save.

Grafana 10.x

  1. On the Grafana homepage, click the image icon.

  2. In the left-side navigation pane, click Dashboards. On the page that appears, select New dashboard from the New drop-down list.

  3. On the New dashboard page, click + Add visualization.

  4. On the right side of the Select data source page, select the data source added in Step 3.

  5. In the A section of the Query tab, select a metric from the Metric and Labels drop-down lists, and then click Run queries.

    image

  6. In the right-side pane, specify the name, type, and graph styles of the chart.

  7. Click Apply.

  8. In the upper-right corner, click the 保存监控大盘 icon. Then, specify the name of the dashboard and the directory in which the dashboard resides.

  9. Click Save.

Step 5: View monitoring data

Grafana 9.x

  1. In the left-side navigation pane of Grafana, click the image icon and click Browse.

  2. On the Browse tab, find the directory and click the dashboard to view the charts.

Grafana 10.x

  1. On the Grafana homepage, click the image icon in the upper-left corner.

  2. In the left-side navigation pane, click Dashboards. Find the directory and click the dashboard to view the charts.