Managed Service for Grafana can query metrics directly from a Managed Service for Prometheus instance. After you connect the two services, you can build dashboards and visualize your Prometheus metrics within your Grafana workspace.
To add a self-managed Prometheus instance deployed on Alibaba Cloud, see Manage VPC data channels.
To add a self-managed Prometheus instance deployed in your own data center, see the Prometheus data source in the Grafana documentation.
Prerequisites
Before you begin, make sure that you have:
A Grafana workspace. To create one, see Create a workspace
Metrics data in the Managed Service for Prometheus instance you want to connect
Log on to Grafana
Log on to the Application Real-Time Monitoring Service (ARMS) console. In the left-side navigation pane, choose .
On the Workspace Management page, find your workspace and click the link in the URL column.
Log on to Grafana with the administrator account and the password you set when you created the workspace.
NoteYou can also click Sign in with Alibaba Cloud to log on with your current Alibaba Cloud account.
Add the Prometheus data source
The following steps apply to both Grafana 9.0.x and 10.0.x. Version-specific UI differences are noted inline.
Open the data source configuration page.
Grafana 9.0.x: In the left-side navigation pane, choose
> Add data source.Grafana 10.0.x: Click the
icon on the homepage. Choose Management > Data sources, then click + Add new data source.
Search for and select Prometheus.
On the Settings tab, configure the following parameters. Configure other parameters based on your requirements. For all available options, see Prometheus data source in the Grafana documentation.
Parameter Description Name A display name for this data source. Specify any name that helps you identify it. URL The URL of the Managed Service for Prometheus instance. Click Save & test. If the message
Data source is workingappears, the connection is successful. You can now create dashboards using this data source.
Create a dashboard panel
After the data source connection succeeds, create a dashboard panel to visualize your Prometheus metrics.
Create a new dashboard.
Grafana 9.0.x: In the left-side navigation pane, choose
> New dashboard, then click Add a new panel.Grafana 10.0.x: Click the
icon on the homepage, click Dashboards, select New dashboard from the New drop-down list, and click + Add visualization.
Select the Prometheus data source you added.
Grafana 9.0.x: On the Query tab of the Edit Panel page, select the data source from the Data source drop-down list.
Grafana 10.0.x: Select the data source from the Select data source dialog box.
In the A section of the Query tab, set the Metric and Labels parameters, then click Run queries. Grafana 9.0.x: Grafana 10.0.x:


In the right-side pane, specify the chart name, type, and graph styles.
Click Apply.
Click the
icon in the upper-right corner, specify a dashboard name and folder, and click Save.
(Optional) Set up Prometheus Node Exporter
This section walks through setting up Prometheus Node Exporter to collect hardware and OS-level metrics from an Elastic Compute Service (ECS) instance, then building a Grafana dashboard from a community template.
Download and start Node Exporter
Download Prometheus Node Exporter from the official Prometheus website, or run the following command:
wget https://github.com/prometheus/node_exporter/releases/download/v1.2.0/node_exporter-1.2.0.linux-amd64.tar.gzExtract the package and start Node Exporter.
Verify that Node Exporter is running by querying its metrics endpoint:
NoteReplace
localhostand the port number as needed for your environment.To verify network access from other ECS instances, try accessing
http://<ECS-IP>:9100/metrics. If the connection fails, check whether a security group rule is blocking port 9100.
curl http://localhost:9100/metrics
Register Node Exporter for service discovery
Choose the option that matches your Prometheus deployment:
Managed Service for Prometheus
Log on to the ARMS console. In the left-side navigation pane, choose .
In the top navigation bar, select the region of your Prometheus instance. Click the instance name.
In the left-side navigation pane, click Settings. On the Settings tab, click Edit Prometheus.yaml and add the Node Exporter endpoint.
Self-managed Prometheus instance
Add the Node Exporter target to your prometheus.yml file:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['<Node-Exporter-IP>:9100']Replace <Node-Exporter-IP> with the IP address of the ECS instance running Node Exporter.
Import the Node Exporter dashboard template
After Node Exporter starts reporting metrics, import a pre-built Grafana dashboard template to visualize the data.
Log on to Grafana. See Log on to Grafana.
Open the dashboard import page.
Grafana 9.0.x: In the left-side navigation pane, click the
icon. On the Browse tab of the Dashboards page, click Import.Grafana 10.0.x: Click the
icon on the homepage, click Dashboards, click New in the upper-right corner, and select Import.
In the Import via grafana.com input box, enter template ID
12884and click Load. Grafana 9.0.x: Grafana 10.0.x:

In the Options section, configure the following parameters. Grafana 9.0.x: Grafana 10.0.x:
Parameter Description Name A display name for the dashboard. Specify any name that helps you identify it. Folder The folder in which to store the dashboard. Unique identifier (UID) Click Change uid to customize the dashboard UID. Prometheus The Prometheus data source to use with this dashboard. 

Click Import.
Click the
icon in the upper-right corner and click Save to save the dashboard.