Prometheus special labels #13217
-
Hello, I have been working with Prometheus configuration for some time, which involved file-based service discovery, special labels such as For context, I am configuring my monitoring system to only work upon file-based service discovery. So in my Prometheus configuration I only have one single Scrape Configuration. Any job will be passed through file. Unfortunately, all you can put into a job configuration is a Now that the context is clear, here's my findings. Thanks to this specific Prometheus documentation bit, I was able to reconstruct the timeline of the relevant steps that Prometheus goes through just before scraping.
Ok, all of the above can be easily found in the documentation. But that wouldn't actually help me solving my problem, if I didn't find out the following "insight knowledge", which I could not find anywhere in the official documentation. Finding 1: Prometheus behaviour is not driven by the configuration elements. It is driven by the special labels!I'm not sure if this should be obvious by the documentation, but I wasn't able to find any mentioning of this anywhere. But once I started suspecting this, all that behaviour I described above of Prometheus setting these special labels just before scraping started making a lot of sense finally. Why would otherwise Prometheus bother setting these special labels if its behaviour was then just driven by the original elements (from which those special labels were populated)? So I came to the conclusion that Prometheus behaviour is actually driven by these special labels, and not by the original elements themselves (by original elements I mean the [original elements] --determine--> [special labels] --drive--> [Prometheus scraping behaviour] Q&A Is my understanding correct? Is it just me or is this not documented anywhere? Finding 2: At any stage, if Prometheus is about to set a special label, and finds that that special label already happens to have a value, then it doesn't touch it (and leaves the value as-is)!This was very important to solve my problem! Suppose I have defined my file-based discoverable configuration as the following: [
{
"targets": [ "myhost:1234" ],
"labels": {
"job": "my-specific-job",
"__metrics_path__": "/api/actuator/prometheus",
"__scheme__": "https",
"__scrape_interval__": "30s"
}
}
] Then, referring to my timeline at the top, during step 1, Prometheus would set the During step 3, Prometheus would set the All these tests I did are also evidence of my "Finding 1", that is Prometheus behaviour is driven by the special labels. Q&A (same questions) Is my understanding correct? Is it just me or is this not documented anywhere? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Turns out both my findings are correct (sort of).
Also yes, the documentation about this can definitely be improved. Source: I had a chat with @SuperQ in the IRC channel who kindly answered my questions. (Feel free to chip in if I've missed anything). |
Beta Was this translation helpful? Give feedback.
Turns out both my findings are correct (sort of).
relabel_configs
turn into a per-target scrape loop configuration item.Also yes, the documentation about this can definitely be improved.
Source: I had a chat with @SuperQ in the IRC channel who kindly answered my questions. (Feel free to chip in if I've missed anything).