This topic describes how to use Grafana to access the Elasticsearch-compatible API of Simple Log Service.
This topic is proprietary information of Alibaba Cloud, and describes the capabilities that are provided by Alibaba Cloud to interact with third-party services. Therefore, the names of third-party companies and services may be referenced in this topic.
Prerequisites
Grafana 8.x.x or Grafana 9.x. x is installed. For more information, see Install Grafana.
Data is collected to a Standard Logstore in Simple Log Service. For more information, see Data collection overview.
At least one field index is created. For more information, see Create indexes.
The AccessKey pair of an Alibaba Cloud account is created. For more information, see AccessKey pair.
We recommend that you use the AccessKey pair of a RAM user. The RAM user must have the permissions to query data in the Logstore. You can use the permission assistant feature to grant permissions to a RAM user. For more information, see Configure the permission assistant feature.
Background information
Grafana is an open-source data visualization and monitoring platform that supports multiple data sources, such as Graphite, InfluxDB, Prometheus, and Elasticsearch. Grafana allows you to configure multiple charts and query data.
If you use Grafana to analyze Elasticsearch data, and want to migrate Elasticsearch data to Simple Log Service, you can use the Elasticsearch-compatible API of Simple Log Service. Then, you can use the Elasticsearch data source plug-in of Grafana to access Simple Log Service for data query and analysis.
Simple Log Service also provides the native Grafana data source plug-in. For more information, see Connect Simple Log Service to Grafana. The following table describes the differences between the plug-ins.
Item | Grafana and Elasticsearch-compatible API | Grafana and Simple Log Service native plug-in |
Grafana data source plug-in | Elasticsearch data source plug-in that is provided by Grafana by default | Simple Log Service data source plug-in that requires manual installation |
Query syntax | Elasticsearch DSL syntax | Simple Log Service index-based query syntax and SQL analysis syntax |
Procedure
In this example, Grafana 8.3.3 is used.
Log on to the Grafana console.
In the left-side navigation pane, choose Configuration > Data Sources.
On the Data Sources tab, click Add data source.
Find and click Elasticsearch.
On the Settings tab, configure the parameters and click Save&test.
The following table describes the parameters. You can keep the default values for other parameters.
Section
Parameter
Description
HTTP
URL
The URL that is used to access data. The URL is in the
https://${project}.${sls-endpoint}/es/
format.${project}
specifies the name of the project.${sls-endpoint}
specifies the endpoint of the Simple Log Service project. For more information, see Endpoints. Example:https://etl-guangzhou.cn-guangzhou.log.aliyuncs.com/es/
.ImportantYou must use the HTTPS protocol.
Auth
Basic auth
Turn on Basic auth.
User
The AccessKey ID of your Alibaba Cloud account.
We recommend that you use the AccessKey pair of a RAM user. The RAM user must have the permissions to query data in the Logstore. You can use the permission assistant feature to grant permissions to a RAM user. For more information, see Configure the permission assistant feature. For information about how to obtain an AccessKey pair, see AccessKey pair.
Password
The AccessKey secret of your Alibaba Cloud account.
We recommend that you use the AccessKey pair of a RAM user. The RAM user must have the permissions to query data in the Logstore. You can use the permission assistant feature to grant permissions to a RAM user. For more information, see Configure the permission assistant feature. For information about how to obtain an AccessKey pair, see AccessKey pair.
Elasticsearch details
Index name
The name of the Elasticsearch index pattern. The name must be in the
${Simple Log Service Project name}.${Logstore name}
format. For example, if a project is named etl-guangzhou and a Logstore is named es_test22, you must set the Index name parameter toetl-guangzhou.es_test22
.Version
Select 7.10+.
After you create a data source, Grafana can access the data that is stored in Simple Log Service. You can create reports based on the data for data analysis and visualized display.