I have job definition as follows:
- job_name: 'test-name' static_configs: - targets: [ '192.168.1.1:9100', '192.168.1.1:9101', '192.168.1.1:9102' ] labels: group: 'development'
Is there any way to annotate targets with labels? For instance, I would like to add 'service-1' label to '192.168.1.1:9100', 'service-2' to '192.168.1.1:9101' etc.
Unfortunately, it is not possible to change the labels on old metrics in Prometheus. The storage is only updated by new scrapes and then it becomes immutable.
Prometheus has a scraping configuration that allows you to add target you want to scrape. This is the documentation (a good starting point). Thanks for the answer. I actually fixed it mapping these configs by editing the configmap.
The answer in Prometheus is target labels. At a minimum you'll have a job label to indicate the type of thing you're monitoring, and an instance label to identify the specific process. You might also have others for the environment, datacenter, team etc.
I have the same question before. Here is my solution:
For you the code may like this:
- job_name: 'development' static_configs: - targets: [ '192.168.1.1:9100' ] labels: service: '1' - targets: [ '192.168.1.1:9101' ] labels: service: '2'
Can be like this
- job_name: 'node' static_configs: - targets: ['192.168.1.117:9100'] labels: instance: 'linux-ina' - targets: ['192.168.1.138:9100'] labels: instance: 'linux-inb'
Tag name can be replaced with instance
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With