Send Prometheus monitoring data to Simple Log Service for analysis and monitoring.
Prerequisites
-
You have created a metricstore. For more information, see Create a metricstore.
-
You have installed Prometheus. For more information, see GETTING STARTED.
-
You have configured data scraping rules in Prometheus. For more information, see scrape_config.
Procedure
Simple Log Service supports the Prometheus Remote Write protocol. To send metrics, enable Remote Write in your Prometheus configuration.
-
Log on to the server where Prometheus is deployed.
-
Open the Prometheus configuration file and configure the
remote_writesection with the following parameters. Replace the example values with your actual information. For more information, see remote_write.url: https://sls-prometheus-test.cn-beijing.log.aliyuncs.com/prometheus/sls-prometheus-test/prometheus-raw/api/v1/write basic_auth: username: access-key-id password: access-key-secret queue_config: batch_send_deadline: 20s capacity: 20480 max_backoff: 5s max_samples_per_send: 2048 min_backoff: 100ms min_shards: 100Parameter
Description
url
The URL of the metricstore in Simple Log Service. The URL has the following format: https://{project}.{sls-endpoint}/prometheus/{project}/{metricstore}/api/v1/write.
-
{sls-endpoint}: The service endpoint. For more information, see Endpoints.
-
{project}: The project name.
-
{metricstore}: The metricstore name.
Important-
If your Prometheus instance runs on the Alibaba Cloud internal network, use an internal network endpoint.
-
To ensure secure data transmission, you must use an HTTPS endpoint.
basic_auth
The authentication credentials. Basic authentication is required to write data to Simple Log Service by using Remote Write.
-
username: The AccessKey ID of your Alibaba Cloud account.
-
password: The AccessKey secret of your Alibaba Cloud account.
For security, use the AccessKey pair of a RAM user with write-only permissions for the project. For more information, see Grant write permissions on a specific project.
queue_config
queue_config configures write policies such as caching and retries.
To avoid excessive invalid network requests, set min_backoff to at least 100 ms and max_backoff to at least 5s.
If you send a large volume of data from Prometheus, use the following queue_config settings:
batch_send_deadline: 20s capacity: 20480 max_backoff: 5s max_samples_per_send: 2048 min_backoff: 100ms min_shards: 100 -
-
Verify that data is being sent to Simple Log Service.
After configuring Prometheus, preview the incoming data in the Simple Log Service console to verify the connection.
-
Log on to the Simple Log Service console.
-
In the Projects section, click the target project.
-
In the left-side navigation pane, choose . On the metricstore tab, find your metricstore and choose .
On the Consumption Preview page, if data appears, the configuration is successful. The data is displayed in a table with Time/Source and Content columns. Each entry contains Prometheus metric information, including the metric name (__name__), labels (__labels__), and value (__value__).
ImportantIf time-series data is written to an SLS metricstore by using the remote write protocol, SLS uses
MetricNameandLabelsas the defaultHashKey. This routes time-series data from different timelines into specific shards to improve data locality on the storage side.
-
What to do next
After Prometheus monitoring data is ingested into Simple Log Service, you can:
-
Query and analyze the Prometheus monitoring data in Simple Log Service. For more information, see Query and analyze time series data.
-
Visualize the Prometheus monitoring data in Grafana. For more information, see Connect time series data to Grafana.
> Consumption Preview