Prometheus Dynamic Configuration Target _ other

Source: Internet
Author: User
Tags docker run

Prometheus Dynamic Configuration target

(Jin Qing's column 2018.4)

The simplest configuration is a static target:

Scrape_configs:
  -job_name: ' Prometheus '

    static_configs:
      -Targets: [' localhost:9090 ', ' localhost:9100 ' ]
        Labels:
          group: ' Prometheus '

After you change this file, you can send a SIGHUP trigger configuration reload.

Prometheus provides a service discovery feature that can discover new targets from a variety of sources, from Consul, DNS, kubernetes, file, and so on.
The simplest of these is the file Discovery service.

For example, the/ROOT/PROMETHEUS/PROMETHEUS.YML configuration is as follows:

Global:
  scrape_interval:15s
  evaluation_interval:15s
scrape_configs:
  -job_name: ' Prometheus '
    static_configs:
      -Targets: [' 127.0.0.1:9090 ', ' 127.0.0.1:9100 ']
        Labels:
          group: ' Prometheus '
  -job_name: ' Test '
    file_sd_configs:
      -Files: ['/etc/prometheus/test_sd_config/*.yml ']
        Refresh _interval:5s

Start Prometheus with Docker:

Docker run-d--net=host \
  -v/root/prometheus:/etc/prometheus \
  --name prometheus-server \
  prom/ Prometheus

Create/root/prometheus/test_sd_config/test.yml as follows

-Targets: ["192.168.93.192:8080"]
  Labels:
    group: "My_test_group"

The test.yml is automatically read within 5s and the new target is added.
Open the Prometheus 9090 port using the browser,
Check the Status of Configuration, Targets, Service Discovery,
You can see the newly added target.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.