Updated on 2024-08-05 GMT+08:00

Reporting Prometheus Data to AOM

On the Settings tab page of the default Prometheus instance or of the Prometheus instance for CCE, or remote write, you can obtain the remote write address of the current Prometheus instance. Native Prometheus metrics can then be reported to AOM through remote write. In this way, time series data can be stored for long.

If the open-source Prometheus has been deployed and is being used, directly go to 4.

Prerequisites

Procedure

  1. Install and start Prometheus. For details, see Prometheus official documentation.
  2. Add an access code.

    1. Log in to the AOM 2.0 console.
    2. In the navigation pane, choose Management > Global Configuration.
    3. In the navigation pane on the left, choose Authentication. Click Add Access Code.
    4. In the dialog box that is displayed, click OK. The system then automatically generates an access code.
    • You can create up to two access codes for each project.
    • An access code is an identity credential for calling APIs. Keep your access code secure.

  3. Obtain the configuration code for Prometheus remote write.

    1. Log in to the AOM 2.0 console.
    2. In the navigation pane on the left, choose Metric Analysis > Prometheus Monitoring. In the instance list, click the target Prometheus instance.
    3. On the displayed page, choose Settings in the navigation pane and obtain the configuration code for Prometheus remote write from the Service Addresses area.

  4. Log in to the target ECS and configure the prometheus.yml file.

    Run the following command to find and start the prometheus.yml file:

    ./prometheus --config.file=prometheus.yml

    Add the configuration code for Prometheus remote write obtained in 3 to the end of the prometheus.yml file.

    The following shows an example. You need to configure the italic part.

    # my global config
    global:
    scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
    evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
    # scrape_timeout is set to the global default (10s).
    
    # Alertmanager configuration
    alerting:
    alertmanagers:
      - static_configs:
      - targets:
    # - alertmanager:9093
    
    # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
    rule_files:
    # - "first_rules.yml"
    # - "second_rules.yml"
    
    # A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
    scrape_configs:
    # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
      - job_name: 'prometheus'
    
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    
    static_configs:
      - targets: ['localhost:9090']
    # Replace the italic content with the configuration code for Prometheus remote write obtained in 3.
    remote_write:
      - url:'https://aom-**.***.{Site domain name suffix}:8443/v1/6d6df***2ab7/58d6***c3d/push'
        tls_config:
          insecure_skip_verify: true
        bearer_token: 'SE**iH'

  5. Check the private domain name.

    In the preceding example, data is reported through the intranet. Therefore, ensure that the host where Prometheus is located can resolve the private domain name.

  6. Restart Prometheus.
  7. View metric data in AOM using Grafana to check whether data is successfully reported after the preceding configurations are modified.