Metricstores of Simple Log Service are compatible with the query API of Prometheus. This topic describes how to connect Simple Log Service as a Prometheus data source to Grafana. You can then send data from Simple Log Service to Grafana and visualize the data in Grafana.
Prerequisites
Grafana is installed. For more information, see Install Grafana.
Time series data is imported to Simple Log Service. For more information, see Collect metric data from Prometheus by using the Remote Write Protocol.
Configure Simple Log Service as a Prometheus data source in Grafana
Log on to Grafana.
In the left-side navigation pane, choose .
On the Data Sources tab, click Add data source.
Move the pointer over the Prometheus card and click Select.
On the Settings tab, set the following parameters.
Parameter or section
Description
Name
Set a name for the data source, for example, Prometheus-01.
HTTP
URL: Enter the URL of the Metricstore. Format: https://{project}.{sls-endpoint}/prometheus/{project}/{metricstore}. Replace {sls-endpoint} with the Simple Log Service endpoint in the region where the project resides. For the list of Simple Log Service endpoints in different regions, see Endpoints. Replace {project} and {metricstore} with the project name and Metricstore name. Example: https://sls-prometheus-test.cn-hangzhou.log.aliyuncs.com/prometheus/sls-prometheus-test/prometheus.
NoteTo ensure secure transmission, use HTTPS.
Whitelisted Cookies: Specify a whitelist for access. This parameter is optional.
Auth
Select the Basic Auth check box.
Basic Auth Details
User: Enter an AccessKey ID.
Password: Enter an AccessKey secret that corresponds to the AccessKey ID.
We recommend that you use an AccessKey pair of a RAM user that has only the permissions to read data from the Simple Log Service project. For information about how to grant a RAM user only the permissions to read data from a specified Simple Log Service project, see The read-only permission on projects.
Click Save & Test.
Import a Simple Log Service dashboard template to Grafana
Perform the following steps to import a Simple Log Service dashboard template to Grafana:
Copy the template ID.
Log on to the dashboard market of Grafana.
Click the template.
On the right side of the page, click Copy ID to Clipboard.
Log on to Grafana.
In the left-side navigation pane, choose .
In the Grafana.com Dashboard field, paste the template ID that you copied in Step 1.
Then, click a blank area to go to the page for data source configuration.
Configure the data source.
In this step, set the parameters based on the data source that you added when you configure Simple Log Service as a Prometheus data source in Grafana. The parameters vary depending on the dashboard template. The parameters may include telegraf and host.
Click Import.
Access Simple Log Service by using the query API of Prometheus
Simple Log Service is compatible with the query API of Prometheus. You can configure Simple Log Service as a Prometheus data source in Grafana or use the Prometheus API to access Simple Log Service. The following table provides examples of the supported API operations.
Operation | Example |
| |
| |
| |
| |
|