简体   繁体   中英

Label Prometheus Instances

I want be able to distinguish between the several servers that I'm reading from. But the only information that I have about the servers is the IP address, but what I wanted to have is a name for each server, instead of the IP.

This is what I can see at the moment

This is my prometheus.yml file:

global:
  scrape_interval: 15s

scrape_configs:    
  - job_name: 'eos-dev'
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['292.268.3.326:8303']
        labels:
          job: 'dev'

  - job_name: 'eos-test'
    scrape_interval: 5s
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['272.41.27.342:8303']
        labels:
          job: 'test'

I tried this solution that Brian Brazil shows, but no luck.

I saw this two one , two questions that are about the same problem, but no luck.

From what I saw the solution is something around relabel_configs but I'm not sure.

Remember that Prometheus is about services, not about hosts (see for example https://www.robustperception.io/one-agent-to-rule-them-all ).

But in any case I think you already have what you are looking for: job-name is transformed into the job label in all your metrics. So in your grafana configuration, replace the label for the IP address (it seems you are using instance ) with job .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM