标记 Prometheus 实例
Label Prometheus Instances
我希望能够区分我正在读取的多个服务器。但是关于服务器的唯一信息是 IP 地址,但我想要的是每个服务器的名称,而不是 IP。
This is what I can see at the moment
这是我的prometheus.yml文件:
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'
我尝试了 this Brian Brazil 展示的解决方案,但没有成功。
我看到这两个 , 问题是关于同一个问题,但运气不好。
据我所知,解决方案大约是 relabel_configs,但我不确定。
请记住,Prometheus 是关于服务的,而不是关于主机的(参见示例 https://www.robustperception.io/one-agent-to-rule-them-all)。
但无论如何我认为您已经拥有了您正在寻找的东西:job-name
被转换为所有指标中的 job
标签。因此,在您的 grafana 配置中,将 IP 地址的标签(似乎您使用的是 instance
)替换为 job
。
我希望能够区分我正在读取的多个服务器。但是关于服务器的唯一信息是 IP 地址,但我想要的是每个服务器的名称,而不是 IP。
This is what I can see at the moment
这是我的prometheus.yml文件:
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'
我尝试了 this Brian Brazil 展示的解决方案,但没有成功。
我看到这两个
据我所知,解决方案大约是 relabel_configs,但我不确定。
请记住,Prometheus 是关于服务的,而不是关于主机的(参见示例 https://www.robustperception.io/one-agent-to-rule-them-all)。
但无论如何我认为您已经拥有了您正在寻找的东西:job-name
被转换为所有指标中的 job
标签。因此,在您的 grafana 配置中,将 IP 地址的标签(似乎您使用的是 instance
)替换为 job
。