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:
Log on to the ARMS console.
In the left-side navigation pane, choose .
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.
NoteIf you use a Prometheus instance that monitors cloud services, select a URL of the HTTP API based on the monitored cloud service.
Optional. To improve data security for read and write operations, click Generate Token to obtain the token of the Prometheus instance.
ImportantAfter 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.
Step 2: Log on to the Grafana system
Log on to the ARMS console. In the left-side navigation pane, choose .
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.
NoteYou 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
In the left-side navigation pane of Grafana, choose > Add data source.
On the Add data source page, click Prometheus.
On the Settings tab, enter a name in the Name field and paste the API URL obtained in Step 1 in the URL field.
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.
Click Save & Test.
Grafana 10.x
On the Grafana homepage, click the icon.
In the left-side navigation pane, choose .
On the Data sources tab, click + Add data source.
On the Add data source page, click Prometheus.
On the Settings tab, enter a name in the Name field and paste the API URL obtained in Step 1 in the URL field.
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.
Click Save & Test.
Step 4: Create a dashboard
Grafana 9.x
In the left-side navigation pane of Grafana, choose > New dashboard.
On the New dashboard page, click Add a new panel.
On the Query tab of the Edit Panel page, select the data source added in Step 3 from the Data source drop-down list.
In the A section of the Query tab, select a metric from the Metric and Labels drop-down lists, and then click Run queries.
In the right-side pane, specify the name, type, and graph styles of the chart.
Click Apply.
In the upper-right corner, click the icon. Then, specify the name of the dashboard and the directory in which the dashboard resides.
Click Save.
Grafana 10.x
On the Grafana homepage, click the icon.
In the left-side navigation pane, click Dashboards. On the page that appears, select New dashboard from the New drop-down list.
On the New dashboard page, click + Add visualization.
On the right side of the Select data source page, select the data source added in Step 3.
In the A section of the Query tab, select a metric from the Metric and Labels drop-down lists, and then click Run queries.
In the right-side pane, specify the name, type, and graph styles of the chart.
Click Apply.
In the upper-right corner, click the icon. Then, specify the name of the dashboard and the directory in which the dashboard resides.
Click Save.
Step 5: View monitoring data
Grafana 9.x
In the left-side navigation pane of Grafana, click the icon and click Browse.
On the Browse tab, find the directory and click the dashboard to view the charts.
Grafana 10.x
On the Grafana homepage, click the icon in the upper-left corner.
In the left-side navigation pane, click Dashboards. Find the directory and click the dashboard to view the charts.