Hello everyone! Today, we’re going to take a deep dive into an interesting setting you might encounter while using Prometheus: honor_labels.
When collecting metrics with Prometheus, you might have experienced moments like, “Huh? Why did my configured label change?” or “My desired label disappeared!” The key to unlocking this mystery is very likely honor_labels! π

π₯ Label Conflicts, What’s Going On?
When Prometheus scrapes metrics, it automatically adds several labels to include useful information about those metrics. The most common ones are the job and instance labels.
job: Indicates which scraping job the metric belongs to.instance: Indicates which target the metric was scraped from.
However, a problem can arise here. What if the metrics of the target we are trying to scrape already contain labels named job or instance? π§
For example, if the target exposes a metric like my_metric{job="my-app-exporter"}, and the Prometheus configuration scrapes this target with job_name: 'api-server', then the label name job will conflict.
The option that determines which label Prometheus chooses in this situation is honor_labels.
π€ honor_labels: false (Default) – Prometheus’s Approach
This setting is the default value for honor_labels. It literally means “do not honor” the target’s labels (false), so labels automatically added by Prometheus take precedence.
- How it works:
- Prometheus uses its own configured
jobandinstancelabels as they are. π‘οΈ - Existing conflicting labels on the target (e.g.,
job) are renamed. - A prefix
exported_is added to their names, changing them to something likeexported_job. π·οΈ
- Example:
- Target Metric:
http_requests_total{job="frontend"} - Prometheus Configuration:
job_name: 'web-crawlers' - Final Scraped Result:
http_requests_total{job="web-crawlers", exported_job="frontend", ...}
As a result, Prometheus’s job label is applied first, and the original job label from the target is renamed to exported_job and preserved.
π honor_labels: true – Respecting the Target’s Labels!
If you change this setting to true, Prometheus behaves in the opposite way. It means “honor” the target’s labels (true), so Prometheus uses the labels provided by the target as they are.
- How it works:
- Labels in the target’s metrics are respected with the highest priority. π
- If a label Prometheus intends to add conflicts in name, Prometheus quietly gives up adding its own label.
- The target’s labels are stored without any changes.
- Example:
- Target Metric:
http_requests_total{job="frontend"} - Prometheus Configuration:
job_name: 'web-crawlers'andhonor_labels: true - Final Scraped Result:
http_requests_total{job="frontend", ...}
As you can see, Prometheus’s job_name setting of ‘web-crawlers’ is ignored, and the job="frontend" label originally held by the target is retained.
π‘ When Should You Use honor_labels: true?
So, when is this option useful? It primarily shines in the following situations:
- When configuring Federation: Used when scraping the
/federateendpoint of another Prometheus server. It’s essential when the original Prometheus already has meaningfuljobandinstancelabels that need to be preserved. - When using Pushgateway: Pushgateway manages its own
jobandinstancelabels, so this is useful when you want to use those labels as they are without overwriting them. - When utilizing Service Discovery: In environments like Kubernetes, when metadata labels obtained through service discovery hold more significant meaning than Prometheus’s
jobname, you can use this to make those labels act as thejoblabel.
π Summary at a Glance
| Setting | honor_labels: false (Default) |
honor_labels: true |
| Priority | Prometheus’s automatically added labels π | Target’s existing labels π |
| Behavior on Conflict | exported_ prefix added to target’s label name |
Prometheus’s labels are discarded |
Resulting job Label |
Prometheus configuration value (job_name) |
Target’s original job label value |
| Primary Use Cases | Most general scraping environments | Federation, Pushgateway, Advanced Service Discovery |
honor_labels is a powerful tool that allows you to finely control Prometheus’s labeling strategy. Understand and utilize this option well to manage cleaner and more meaningful metrics!π
Leave a Reply