You can view Managed Service for Prometheus data in your self-managed Grafana by adding the dedicated API endpoint provided by Managed Service for Prometheus as a Managed Service for Prometheus data source.
Prerequisites
You have a self-managed Grafana instance installed and running.
Step 1: Obtain the API endpoint
Obtain the API endpoint for connecting Managed Service for Prometheus to your self-managed Grafana:
-
Log on to the Cloud Monitor console.
-
In the navigation pane on the left, choose to open the instance list for Managed Service for Prometheus.
-
Click the name of the instance to open its details page. In the navigation pane on the left, click Settings. On the Settings tab, copy the public or internal HTTP API endpoint based on your requirements.
NoteFor a Prometheus instance created for a cloud service, select the HTTP API endpoint that corresponds to the type of the integrated cloud service.
The HTTP API endpoint (for Grafana read) is available for both public and internal networks. Example of a public endpoint:
http://cn-hangzhou.arms.aliyuncs.com:9090/api/v1/prometheus/{instance-id}. Example of an internal endpoint:http://cn-hangzhou-intranet.arms.aliyuncs.com:9090/api/v1/prometheus/{instance-id}. You can click the copy icon next to an endpoint to copy it. -
Optional: To enhance security for the Grafana connection, click Generate Token to get an authentication token for the Prometheus instance.
ImportantAfter you obtain a token, you must configure it when you add the data source in Grafana. Otherwise, Grafana may fail to read data from Managed Service for Prometheus.
Record the Token value. You can click the copy icon to copy it. Then, obtain the Remote Read endpoint. The public endpoint format is
http://cn-hangzhou.arms.aliyuncs.com:9090/api/v1/prometheus/xxx/api/v1/read, and the internal endpoint format ishttp://cn-hangzhou-intranet.arms.aliyuncs.com:9090/api/v1/prometheus/xxx/api/v1/read. In these examples,xxxrepresents the actual instance ID displayed in the console.
Step 2: Log on to Grafana
-
Log on to the Managed Service for Grafana console. In the left-side navigation pane, click Workspace Management.
-
On the Workspace Management page, find the target workspace and click the URL to its right to open Grafana.
NoteIf you are prompted to sign in, use the Grafana Admin account and password you configured for the workspace. Alternatively, click Sign in with Alibaba Cloud to sign in with the Alibaba Cloud account that you used to purchase the workspace.
Step 3: Add a data source
Add the API endpoint from Step 1 as a data source in Grafana:
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 for the data source and paste the API endpoint from Step 1 into the URL field.
-
Optional: In the Custom HTTP Headers section, click +Add header. Set the Header field to
Authorizationand the Value field to the authentication token from 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 for the data source and paste the API endpoint from Step 1 into the URL field.
-
Optional: In the Custom HTTP Headers section, click +Add header. Set the Header field to
Authorizationand the Value field to the authentication token from Step 1. -
Click Save & Test.
Step 4: Create a dashboard panel
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 Edit Panel page, on the Query tab, from the Data source drop-down list, select the data source that you added in Step 3.
-
On the Query tab, in section A, select a metric and labels 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.
-
In the Select data source dialog box that appears, select the data source that you added in Step 3.
-
On the Query tab, in section A, select a metric and labels 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 Grafana left navigation bar, click the
icon, and then click Browse. -
On the Browse tab, navigate to the folder where you saved your dashboard and click the dashboard to open it.
Grafana 10.x
-
On the Grafana homepage, click the
icon in the upper-left corner of the page. -
In the navigation pane on the left, choose Dashboards. Navigate to the folder where you saved your dashboard and click the dashboard to open it.