All Products
Search
Document Center

Managed Service for Grafana:Add and use a Managed Service for Prometheus data source

Last Updated:Aug 27, 2024

This topic describes how to add and use a Managed Service for Prometheus data source in Grafana.

Note
  • 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

  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 2: Add a Managed Service for Prometheus data source

Grafana 9.0.x

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

  2. On the Add data source page, search for and click Prometheus.

  3. 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.

  4. Click Save & test.

    If the Data source is working message appears, the data source is added.

Grafana 10.0.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 page, click + Add new data source.

  4. On the Add data source page, search for and click Prometheus.

  5. 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.

  6. 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

  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 that you added in Step 2 from the Data source drop-down list.

  4. In the A section of the Query tab, configure the Metric and Labels parameters 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.0.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 dialog box, select the data source that you added in Step 2.

  5. In the A section of the Query tab, configure the Metric and Labels parameters 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.

(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.

  1. 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
  2. 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.
  3. Add the IP address of Prometheus Node Exporter for service discovery.

    • Managed Service for Prometheus:

      1. Log on to the Application Real-Time Monitoring Service (ARMS) console. In the left-side navigation pane, choose Managed Service for Prometheus > Instances.

      2. 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.

      3. 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

  1. Log on to the Grafana console. For more information, see the Step 1: Log on to the Grafana console section of this topic.

  2. In the left-side navigation pane, click the image icon.

  3. On the Browse tab of the Dashboards page, click Import.

  4. 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.

    image

  5. 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.

    image

  6. Click Import.

  7. Click the 保存监控大盘 icon in the upper-right corner. In the Save dashboard panel, click Save. The dashboard is created.

Grafana 10.0.x

  1. Log on to the Grafana console. For more information, see the Step 1: Log on to the Grafana console section of this topic.

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

  3. 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.

  4. 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.

    image

  5. 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.

    image

  6. Click Import.

  7. Click the 保存监控大盘 icon in the upper-right corner. In the Save dashboard panel, click Save. The dashboard is created.