Import open source Prometheus data through remote write

更新时间:
复制 MD 格式

When you run self-managed Prometheus instances alongside Managed Service for Prometheus, you need a way to centralize metrics without replacing your existing setup. The remote write interface lets you forward metrics from any self-managed Prometheus server to a Managed Service for Prometheus instance, so you can use Alibaba Cloud dashboards for all your monitoring data.

Prerequisites

Before you begin, make sure that you have:

  • A Managed Service for Prometheus instance. For more information, see the Create a Prometheus instance section of the Manage Prometheus instances topic

  • An AccessKey pair (AccessKey ID and AccessKey secret) for authentication. For more information, see Obtain an AccessKey pair

Grant a RAM user permissions on ARMS

Note

Skip the following steps if you use an Alibaba Cloud account's own AccessKey pair. The following steps apply only when you use a Resource Access Management (RAM) user's AccessKey pair for remote write authentication.

If the Managed Service for Prometheus instance belongs to an Alibaba Cloud account but you use a RAM user's AccessKey pair for remote write, grant the RAM user full access to Application Real-Time Monitoring Service (ARMS):

  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 target RAM user.

  5. In the Policy section, search for AliyunARMSFullAccess, click the policy name to add it to the Selected Policy list, and then click Grant permissions.

    Note

    The AliyunARMSFullAccess policy grants full permissions on ARMS, including the ability to view, modify, and delete instances.

Obtain the remote write URL

  1. Log on to the ARMS console.

  2. In the left-side navigation pane, choose Managed Service for Prometheus > Instances.

  3. In the top navigation bar, select the region where your Prometheus instance resides. Find the target instance and click Settings in the Actions column.

  4. On the Settings tab, copy the remote write URL. The Settings tab provides two remote write URLs:

    URL typeWhen to use
    InternetYour Prometheus server is outside Alibaba Cloud or in a different region
    Internal networkYour Prometheus server runs in the same region on Alibaba Cloud

    image

Configure the Prometheus server

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

  2. Open prometheus.yml and add the remote_write section. Replace the placeholders with your actual values, then save the file.

    global:
      scrape_interval: 15s
      evaluation_interval: 15s
    scrape_configs:
      - job_name: 'prometheus'
        static_configs:
        - targets: ['localhost:9090']
    remote_write:
      - url: "<your-remote-write-url>"
        basic_auth:
          username: <your-access-key-id>
          password: <your-access-key-secret>
    PlaceholderDescriptionExample
    <your-remote-write-url>Remote write URL obtained in the previous sectionhttp://ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242/api/prom_write
    <your-access-key-id>AccessKey ID of your Alibaba Cloud account or RAM userLTAI5tXxx
    <your-access-key-secret>AccessKey secret of your Alibaba Cloud account or RAM userxXxXxXx
    Note

    The basic_auth credentials are required for both Internet and internal network remote write URLs. If you use a RAM user's AccessKey pair, grant the RAM user permissions on ARMS first.

  3. Restart or reload Prometheus to apply the new configuration.

Verify the data import

  1. Log on to the ARMS console.

  2. In the left-side navigation pane, choose Managed Service for Prometheus > Instances.

  3. In the top navigation bar, select the region where your instance resides. Click the instance name to open the instance details.

  4. In the left-side navigation pane, click Dashboards. Click a dashboard name to verify that the imported metrics appear. If the dashboard shows metrics from your self-managed Prometheus instance, the remote write configuration is working correctly.

Limits

  • The remote write interface does not support HTTP/2.