This topic describes how to add and use a Managed Service for Prometheus data source in Grafana.
For information about how to add a self-managed Prometheus data source that is deployed on Alibaba Cloud, see Manage VPC data channels.
For information about how to add a self-managed Prometheus data source that is deployed in your data center, see Prometheus data source.
Prerequisites
A Grafana workspace is created. For more information, see Create a workspace.
Data exists in the Managed Service for Prometheus data source.
Step 1: Log on to the Grafana console
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 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 2: Add a Managed Service for Prometheus data source
Grafana 9.0.x
In the left-side navigation pane of Grafana, choose
> Add data source.
On the Add data source page, search for and click Prometheus.
On the Settings tab, set the following parameters.
Parameter
Description
Name
The name of the data source. You can specify a custom name.
URL
The URL of the Managed Service for Prometheus instance.
Configure other parameters based on your business requirements. For more information, see Prometheus data source.
Click Save & test.
If the
Data source is working
message appears, the data source is added.
Grafana 10.0.x
On the Grafana homepage, click the
icon.
In the left-side navigation pane, choose .
On the Data sources page, click + Add new data source.
On the Add data source page, search for and click Prometheus.
On the Settings tab, set the following parameters.
Parameter
Description
Name
The name of the data source. You can specify a custom name.
URL
The URL of the Managed Service for Prometheus instance.
Configure other parameters based on your business requirements. For more information, see Prometheus data source.
Click Save & test.
If the
Data source is working
message appears, the data source is added.
Step 3: Create a dashboard panel
Grafana 9.0.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 that you added in Step 2 from the Data source drop-down list.
In the A section of the Query tab, configure the Metric and Labels parameters 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.0.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 dialog box, select the data source that you added in Step 2.
In the A section of the Query tab, configure the Metric and Labels parameters 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.
(Optional) Step 4: Install Prometheus Node Exporter
The following example shows how to create a Grafana dashboard based on a Grafana template. The Grafana template is used with Prometheus Node Exporter to monitor a node in an Elastic Compute Service (ECS) instance.
- Download Prometheus Node Exporter.
- Download Prometheus Node Exporter from the official website of Prometheus .
- Download Prometheus Node Exporter by running the following command.
wget https://github.com/prometheus/node_exporter/releases/download/v1.2.0/node_exporter-1.2.0.linux-amd64.tar.gz
Check the connectivity of Prometheus Node Exporter.
Start Prometheus Node Exporter and run the following command:
curl http://localhost:9100/metrics
Note- Replace the
localhost
and port in the command based on your business requirements. - We recommend that you try to access http:// [ECS IP]:9100/metrics from other ECS instances to check whether the network connectivity is blocked by a security group rule.
- Replace the
Add the IP address of Prometheus Node Exporter for service discovery.
Managed Service for Prometheus:
Log on to the Application Real-Time Monitoring Service (ARMS) console. In the left-side navigation pane, choose .
In the top navigation bar, select the region in which the Managed Service for Prometheus instance resides. In the Instances section, click the name of the instance that you want to manage.
On the instance details page, click Settings in the left-side navigation pane. On the Settings tab, click Edit Prometheus.yaml to add the IP address of Prometheus Node Exporter that is specified in the preceding command.
Self-managed Prometheus instance:
Add the IP address of Prometheus Node Exporter to the Prometheus.yml file.
scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['[Node Exporter IP]:9100']
(Optional) Step 5: Configure the Prometheus Node Exporter dashboard
Grafana 9.0.x
Log on to the Grafana console. For more information, see the Step 1: Log on to the Grafana console section of this topic.
In the left-side navigation pane, click the
icon.
On the Browse tab of the Dashboards page, click Import.
On the Import page, enter the ID of the Node Grafana template, which is 12884, in the Import via grafana.com input box and click Load.
In the Options section of the page that appears, configure the parameters that are described in the following table.
Parameter
Description
Name
The dashboard name. You can specify a custom name.
Folder
The directory in which the dashboard is stored.
Unique identifier (UID)
You can click Change uid to customize the unique identifier (UID) of the dashboard.
Prometheus
The Prometheus data source from which you want to import data.
Click Import.
Click the
icon in the upper-right corner. In the Save dashboard panel, click Save. The dashboard is created.
Grafana 10.0.x
Log on to the Grafana console. For more information, see the Step 1: Log on to the Grafana console section of this topic.
On the Grafana homepage, click the
icon.
In the left-side navigation pane, click Dashboards. On the page that appears, click New in the upper-right corner, and then click Import from the drop-down list.
On the Import dashboard page, enter the ID of the Node Grafana template, which is 12884, in the Import via grafana.com input box and click Load.
In the Options section of the page that appears, configure the parameters that are described in the following table.
Parameter
Description
Name
The dashboard name. You can specify a custom name.
Folder
The directory in which the dashboard is stored.
Unique identifier (UID)
You can click Change uid to customize the unique identifier (UID) of the dashboard.
Prometheus
The Prometheus data source from which you want to import data.
Click Import.
Click the
icon in the upper-right corner. In the Save dashboard panel, click Save. The dashboard is created.