This topic describes how to use Grafana to view the monitoring data collected from Elastic Compute Service (ECS), ApsaraDB RDS, and Server Load Balancer (SLB) in a visualized mode.

Procedure

  1. Install the Grafana software.
    Note The following example demonstrates how to install Grafana on CentOS. For more information about how to install Grafana on other operating systems, see Grafana official documentation.
    1. Log on to the server as the root user.
    2. Run the following commands to install Grafana:
      Note For more information about the software versions of Grafana and the operating systems that Grafana supports, visit the Grafana download page. In the following example, the Grafana installation package is grafana-8.0.6-1.x86_64.rpm, which indicates Grafana 8.0.6 for Linux.
      • Method 1:

        yum install https://dl.grafana.com/oss/release/grafana-8.0.6-1.x86_64.rpm

      • Method 2:

        wget https://dl.grafana.com/oss/release/grafana-8.0.6-1.x86_64.rpm

        sudo yum localinstall grafana-8.0.6-1.x86_64.rpm

    3. Run the following command to start the Grafana service:
      service grafana-server start
  2. Optional. Install Grafana panel plug-ins.

    If you need to view the monitoring data on a Grafana panel, such as Pie Chart, Gantt, or Worldmap Panel, you must install the corresponding panel plug-in. For more information about how to install Grafana panel plug-ins, visit the Grafana panel plug-in page.

  3. Install the CloudMonitor data source plug-in.
    Note The latest version of the plug-in is v2.0.1. Alert rules cannot be set for the monitoring data in this version.
    1. Run the following commands to download the plug-in to the /var/lib/grafana/plugins/ directory:

      cd /var/lib/grafana/plugins/

      wget https://github.com/aliyun/aliyun-cms-grafana/releases/download/v2.0/aliyun_cms_grafana_datasource_v2.0.1.tar.gz

    2. Run the following command to decompress the plug-in to the aliyun_cms_grafana_datasource directory:
      tar -xzf aliyun_cms_grafana_datasource_v2.0.tar.gzc
    3. Configure the plug-in.
      1. Run the following commands to open the configuration file named defaults.ini in /usr/share/grafana/conf:

        cd /usr/share/grafana/conf

        vi defaults.ini

      2. Set the allow_loading_unsigned_plugins parameter to aliyun_cms_grafana_datasource. This allows Grafana to run the CloudMonitor data source plug-in that is not signed.
        The following code demonstrates how to set the allow_loading_unsigned_plugins parameter to aliyun_cms_grafana_datasource:
        allow_loading_unsigned_plugins = aliyun_cms_grafana_datasource
      3. Press the Esc key, enter :wq, and then press the Enter key to save and close the defaults.ini file.
    4. Run the following command to restart the Grafana service:
      service grafana-server restart
  4. Create a CloudMonitor data source.
    Log on to Grafana after it is installed. The default port is 3000 and the default username is admin.
    Notice To prevent security risks, we recommend that you change the password the first time you log on to Grafana.
    1. Log on to Grafana.
      The format of the logon URL is https://Grafana server IP address:3000. For example, it can be https://192.168.XX.XX:3000.
    2. In the left-side navigation pane, click the Configuration icon.
    3. On the Data Sources tab, click Add data source in the upper-right corner.
    4. On the Add data source page, click CMS Grafana Service at the bottom.
    5. Enter the name and account information of the CloudMonitor data source.
      Parameter Description
      Name The name of the data source. You can use the default name CMS Grafana Service.
      Aliyun UserId The ID of your Alibaba Cloud account.
      AccessKeyId The AccessKey ID of your Alibaba Cloud account or a RAM user within the Alibaba Cloud account. For more information about how to obtain an AccessKey ID, see Obtain an AccessKey pair.
      Note The RAM user must be created by the current Alibaba Cloud account and authorized to read CloudMonitor data.
      AccessKey The AccessKey secret of your Alibaba Cloud account or a RAM user within the account. For more information about how to obtain an AccessKey secret, see Obtain an AccessKey pair.
      Note The RAM user must be created by the current Alibaba Cloud account and authorized to read CloudMonitor data.
    6. Click Save & Test.
  5. Add a dashboard and a monitoring chart.
    1. In the left-side navigation pane, click the Create icon.
    2. On the New dashboard page, click Add an empty panel.
    3. On the Query tab, select the CMS Grafana Service data source and configure a metric for a specified Alibaba Cloud service.
      Metric
      The following table describes the parameters that are used to configure a metric for a specified Alibaba Cloud service.
      Parameter Description
      Namespace The namespace of the monitoring data that is reported. Specifies the value in the format of acs_Service name.

      For more information, see Appendix 1: Metrics.

      Metric The name of the metric for which the monitoring data is reported.

      For more information, see Appendix 1: Metrics.

      Period The interval at which the monitoring data is reported. Unit: seconds.

      For more information, see Appendix 1: Metrics.

      Group The name and ID of the application group for which data of the specified metric is reported.
      Dimensions The dimensions that specify the resources for which the monitoring data is reported.

      Specify a dimension in the format of a key-value pair, such as instanceId:i-2ze2d6j5uhg20x47****. You can specify multiple dimensions at a time.

      For more information, see Appendix 1: Metrics.

      Y - column The statistical method that is used to report the monitoring data, such as Average, Maximum, Minimum, and Sum.

      For more information, see Appendix 1: Metrics.

    4. In the right-side pane, set the name, type, and layout of the monitoring chart.
    5. In the upper-right corner, click Apply.
      The monitoring chart is created.
    6. In the upper-right corner, click the Save icon and set the name of the dashboard and the directory where it resides.
    7. Click Save.
      The dashboard is created.
  6. View monitoring data.
    1. In the left-side navigation pane, choose Dashboard > Manage.
    2. On the Manage tab, click the dashboard.
      View all monitoring charts on the dashboard.