All Products
Search
Document Center

Managed Service for Prometheus:Configure open source Prometheus to read monitoring data from Managed Service for Prometheus by using a remote read URL

Last Updated:Sep 19, 2024

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.

  1. Log on to the RAM console as a RAM administrator or with an Alibaba Cloud account.

  2. In the left-side navigation pane, choose Permissions > Grants.

  3. On the Permission page, click Grant Permission.

  4. In the Principal section of the Grant Permission panel, select the RAM user to whom you want to grant read and write permissions.

  5. 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

  1. Log on to the Managed Service for Prometheus console.

  2. In the left-side navigation pane, click Instances.

  3. 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.

  4. On the Settings tab, copy the remote read URL for reading data over the Internet or internal network.

    image

Step 3: Configure open source Prometheus

  1. Install open source Prometheus. For more information, see DOWNLOAD.

  2. 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
  3. Restart open source Prometheus.

Step 4: View the retrieved monitoring data in open source Prometheus

  1. Use a web browser to log on to open source Prometheus.

    http://localhost:9090
  2. On the Prometheus page, click Graph in the top navigation bar.

  3. 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)

    image