Managed Service for Prometheus provides a standard remote read interface, which allows open source Prometheus to remotely read monitoring data from Managed Service for Prometheus. This topic describes how to configure open source Prometheus to read monitoring data from Managed Service for Prometheus by using a remote read URL.
Limits
The remote read interface does not support HTTP/2.
Prerequisites
A Managed Service for Prometheus instance is created. For more information, see the Create a Prometheus instance section of the Manage Prometheus instances topic.
Step 1: Optional. Grant read and write permissions on ARMS to a RAM user
If your Prometheus instance is created by using an Alibaba Cloud account and you want to use the AccessKey ID and AccessKey secret of a Resource Access Management (RAM) user to perform remote read and write operations, you must first grant read and write permissions on Application Real-Time Monitoring Service (ARMS) to the RAM user.
Log on to the RAM console as a RAM administrator or with an Alibaba Cloud account.
In the left-side navigation pane, choose .
On the Permission page, click Grant Permission.
In the Principal section of the Grant Permission panel, select the RAM user to whom you want to grant read and write permissions.
In the Policy section, search for an ARMS permission policy, select the policy name to add it to the Selected Policy section, and then click Grant permissions.
The following system policies provide full permissions and read permissions on Application Real-Time Monitoring Service (ARMS). You can attach one of the policies to a RAM user on demand.
AliyunARMSFullAccess
: provides full permissions on ARMS. After you attach this policy to a RAM user, the RAM user has full permissions on instances managed in ARMS. For example, the RAM user can view, modify, and delete instances.AliyunARMSReadOnlyAccess
: provides read permissions on ARMS. After you attach this policy to a RAM user, the RAM user has permissions to view instances managed in ARMS. The RAM user does not have permissions to modify instances, delete instances, or perform other operations.
Step 2: Obtain a remote read URL
Log on to the Managed Service for Prometheus console.
In the left-side navigation pane, click Instances.
In the top navigation bar, select the region where your Prometheus instance resides. On the Instances page, find the instance that you want to manage and click Settings in the Actions column.
On the Settings tab, copy the remote read URL for reading data over the Internet or internal network.
Step 3: Configure open source Prometheus
Install open source Prometheus. For more information, see DOWNLOAD.
Open the configuration file named Prometheus.yml, add the following content to the end of the file, replace the URL below
remote_read
with the remote read URL you obtained in Step 2, and then save the file.global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] remote_read: # Replace with the remote read URL that you obtained. - url: "http://ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242/api/prom_read" read_recent: true
Restart open source Prometheus.
Step 4: View the retrieved monitoring data in open source Prometheus
Use a web browser to log on to open source Prometheus.
http://localhost:9090
On the Prometheus page, click Graph in the top navigation bar.
On the Graph tab, enter a SQL statement into the search box and click Execute on the right side of the search box.
For example, you can enter the following SQL statement to query the CPU utilization of an instance with the specified IP address:
100 - (avg by (instance) (rate(node_cpu_seconds_total{instance="IP address:9100", mode="idle"}[5m])) * 100)