This topic describes how to use Grafana to view monitoring data from CloudMonitor.
CloudMonitor provides monitoring data of the core services of Alibaba Cloud. It can also display your custom monitoring data. In addition to viewing the monitoring data in the CloudMonitor console, you can use the popular data visualization tool Grafana to display the data.
- Download and install Grafana.
This topic takes the CentOS operating system as an example. You can install Grafana on CentOS in either of the following ways:
yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.0-1.x86_64.rpm
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.0-1.x86_64.rpm sudo yum localinstall grafana-5.3.0-1.x86_64.rpm
For more information about how to install Grafana, see Grafana official documentation.
- Start Grafana.
After Grafana is downloaded and installed, run the service grafana-server start command to start it.
- Install the CloudMonitor data source plug-in.
Confirm the plug-in directory of Grafana. For example, the plug-in directory is
/var/lib/grafana/plugins/on CentOS. Install the CloudMonitor data source plug-in in this directory, and restart the grafana-server service.
Run the following commands to install the plug-in on CentOS:
cd /var/lib/grafana/plugins/ git clone https://github.com/aliyun/aliyun-cms-grafana.git service grafana-server restart
You can also download aliyun-cms-grafana.zip from GitHub, decompress it, and upload the plug-in to the /grafana/plugins/ directory. Then, restart the grafana-server service.Note The current version of the CloudMonitor data source plug-in does not support setting alert rules for the monitoring data.
- Configure the CloudMonitor data source plug-in.
Log on to Grafana after it is installed. The default port number is 3000, and the default username and password are both admin.
- On the Grafana homepage, choose Configuration > Data Sources.
- On the Data Sources page, click Add data source in the upper-right corner.
- Set parameters for the CloudMonitor data source.
Parameter Description Data source Name: the name of the data source. Type: the type of the data source. Select CMS Grafana Service. HTTP
URL: the endpoint of the data source, for example,
http://metrics.cn-shanghai.aliyuncs.com. For more information, see Call CloudMonitor APIs.
Access: the access method of the data source. Retain the default setting.
Auth The authentication configuration. Retain the default setting. cloudmonitor service details Enter the AccessKey ID and AccessKey secret of an account that has the required read and write permissions. We recommend that you use the AccessKey ID and AccessKey secret of a Resource Access Management (RAM) user.
- After the parameters are set, click Save & Test to add the data source.
- Create a dashboard.
- On the Grafana homepage, choose Dashboards > Manage. The Manage page appears.
- Click +Dashboard to create a dashboard. You can also click +Folder to create a folder and then click +Dashboard. Alternatively, you can click +Import to import a dashboard.
- Configure a graph.
- After a dashboard is created, choose New Panel > Add > Graph and click Panel Title. In the dialog box that appears, click Edit.
- On the Metrics tab, set Data Source to cms-grafana.
- Set other parameters such as Project, Metric, Period, Dimensions, Y - column, and
X - column [time]. For more information about how to set Project, Metric, and Period, see DescribeMetricList. The other parameters are described as follows:
Group: the application group created under your Alibaba Cloud account in CloudMonitor.
Dimensions: the instances from which latest monitoring data is collected for the specified project and metric. If you set this parameter to Group, monitoring data is collected from all instances in the specified application group.
Y - column: the monitoring data to be displayed in the Y-axis. You can select more than one option.
X - column: Set it to timestamp.
Y - column describe: Enter the description of each option selected in Y - column.
For more information about the graph, click here.Note
- You can manually enter values for all the parameters by following the instructions in DescribeMetricList.
- You can enter null to invalidate any of the parameters.
- If the value of the Dimensions parameter is incomplete, refresh the page or manually enter the instance IDs in the required format.
Custom monitoring data:
For custom monitoring data, you need to manually set the following parameters:
- Project: Enter acs_customMetric_ ID of your Alibaba Cloud account.
- Metric: Enter the name of the metric for reporting the custom monitoring data.
- Period: Enter the time period for reporting the custom monitoring data.
- Group: Enter the ID of the application group for which the custom monitoring data is reported.
- Dimensions: Enter the dimension for reporting the custom monitoring data. Currently,
you must manually enter the parameter value. Only one dimension is supported. If you
enter multiple dimensions, only the first one is valid.
Note If the dimensions are in the format of env: public, step: 5-ReadFromAlertOnline in the CloudMonitor console, you need to replace the commas (,) with ampersands (&).
- Y - column: Enter options for aggregating the monitoring data, including Average, Maximum, Minimum, Sum, SampleCount, P10, P20, and P99.
- X - column: Set it to timestamp.
- Configure the Singlestat panel.
- Choose New Panel > Add > Singlestat and click Panel Title. In the dialog box that appears, click Edit.
- On the Metrics tab, set the parameters by following the instructions provided in step 4.
The following figure shows an example of a configured Singlestat panel.For more information about Singlestat, click here.
- View the monitoring data.
After the preceding steps are completed, you can view the monitoring data in the created dashboard.