Help Center/ Application Operations Management/ User Guide (2.0)/ Prometheus Monitoring/ Reading Prometheus Instance Data Through Remote Read
Updated on 2024-05-27 GMT+08:00

Reading Prometheus Instance Data Through Remote Read

Prometheus monitoring provides the remote read API, which can categorize a series of Prometheus protocol data sources into oen single data source for query. This section describes how to read AOM Prometheus instance data through the remote read API when you are using self-built Prometheus.

Remote Read Configuration

You are advised to set a prometheus.yml file. The following shows the procedure:

  1. Log in to the AOM 2.0 console.
  2. In the navigation pane on the left, choose Prometheus Monitoring > Instances. In the instance list, click the target Prometheus instance.
  3. On the instance details page, choose Settings in the navigation pane to obtain the service address of the current instance.

    Click the Intranet or Public Network tab to obtain the configuration code for Prometheus remote read in the intranet or public network. Click on the right of the code to copy the code to the corresponding file.

    Remote read configuration:

    remote_read:
      - url: 'https://aom.{region_name}.{Site domain name suffix}/v1/{project_id}/{prometheus_instance_id}/api/v1/read'
        tls_config:
          insecure_skip_verify: true
         bearer_token: '8H**LP'
         read_recent: true

Complete Configuration Items of Remote Read

The configuration items in brackets ([]) are optional. (The following lists the configurations of Prometheus v2.40. Some configuration items may be unavailable in earlier versions. For details, see Prometheus official documents.)

# API URL of the target Prometheus instance for remote read
url: <string>
 
# Unique name of a configuration for remote read
[ name: <string> ]
 
# Filtering conditions that must be contained in PromQL for remote read
required_matchers:
  [ <labelname>: <labelvalue> ... ]
 
# Timeout for remote read query
[ remote_timeout: <duration> | default = 1m ]
 
# Custom headers attached to remote read requests, which cannot overwrite the headers added by Prometheus
headers:
  [ <string>: <string> ... ]
 
# Whether to directly read metrics from the local storage during Prometheus remote read
[ read_recent: <boolean> | default = false ]
 
# Add an authorization header for each remote read request. Select either password or password_file.
basic_auth:
  [ username: <string> ]
  [ password: <secret> ]
  [ password_file: <string> ]
 
# Custom authorization header configuration
authorization:
  # Authentication type
  [ type: <string> | default: Bearer ]
  #Authentication key. Select either credentials or credentials_file.
  [ credentials: <secret> ]
# Obtain the key from a file.
  [ credentials_file: <filename> ]
 
# OAuth 2.0 authentication, which cannot be used together with basic_auth authorization
oauth2:
  [ <oauth2> ]
 
# TLS configuration
tls_config:
  [ <tls_config> ]
 
# Proxy URL
[ proxy_url: <string> ]
 
# Whether 3XX redirection is allowed
[ follow_redirects: <boolean> | default = true ]
 
# Whether to enable HTTP2
[ enable_http2: <bool> | default: true ]
 
# Whether to attach external_labels during remote read
[ filter_external_labels: <boolean> | default = true ]