You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Visualizing Target Relabeling Rules in Prometheus 3.8.0
3
+
created_at: 2025-12-02
4
+
kind: article
5
+
author_name: Julius Volz (@juliusv)
6
+
---
7
+
8
+
Prometheus' [target relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config) feature allows you to adjust the labels of a discovered target or even drop the target entirely. Relabeling rules, while powerful, can be hard to understand and debug. Your rules have to match the expected labels that your service discovery mechanism returns, and getting any step wrong could label your target incorrectly or accidentally drop it.
9
+
10
+
To help you figure out where things go wrong (or right), Prometheus 3.8.0 [just added a relabeling visualizer](https://github.com/prometheus/prometheus/pull/17337) to the Prometheus server's web UI that allows you to inspect how each relabeling rule is applied to a discovered target's labels. Let's take a look at how it works!
11
+
12
+
<!-- more -->
13
+
14
+
## Using the relabeling visualizer
15
+
16
+
If you head to any Prometheus server's "Service discovery" page (for example: https://demo.promlabs.com/service-discovery), you will now see a new "show relabeling" button for each discovered target:
<p>Sorry, your browser does not support videos.</p>
25
+
</video>
26
+
27
+
The visualizer shows you:
28
+
29
+
* The **initial labels** of the target as discovered by the service discovery mechanism.
30
+
* The details of **each relabeling rule**, including its action type and other parameters.
31
+
***How the labels change** after each relabeling rule is applied, with changes, additions, and deletions highlighted in color.
32
+
* Whether the target is ultimately **kept or dropped** after all relabeling rules have been applied.
33
+
* The **final output labels** of the target if it is kept.
34
+
35
+
To debug your relabeling rules, you can now read this diagram from top to bottom and find the exact step where the labels change in an unexpected way or where the target gets dropped. This should help you identify misconfigurations in your relabeling rules more easily.
36
+
37
+
## Conclusion
38
+
39
+
The new relabeling visualizer in the Prometheus server's web UI is a powerful tool to help you understand and debug your target relabeling configurations. By providing a step-by-step view of how each relabeling rule affects a target's labels, it makes it easier to identify and fix issues in your setup. Update your Prometheus servers to 3.8.0 now to give it a try!
Copy file name to clipboardExpand all lines: docs/instrumenting/exposition_formats.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,6 +167,18 @@ When such features are enabled either by feature flag
167
167
appropriate configuration option (`scrape_native_histograms: true`) then
168
168
Protobuf will be favored over other exposition formats.
169
169
170
+
## HTTP Content-Type requirements
171
+
172
+
Starting with Prometheus 3.0, scrape targets **must** return a valid `Content-Type` header for the metrics endpoint. If the `Content-Type` is missing, unparsable, or not a supported media type, **the scrape will fail**. See changes in [scrape protocols](https://prometheus.io/docs/prometheus/latest/migration/#scrape-protocols) in the migration guide for details.
173
+
174
+
See each of the exposition format sections for the accurate HTTP content types.
175
+
176
+
### ScrapeProtocols vs Content-Type
177
+
178
+
Prometheus scrape config offers scrape protocol negotiation based on the content-type using the [`scrape_protocols`](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config) config. For the Prometheus user convenience the scrape protocols are referenced by a unique name that maps to the concrete content-type. See [Protocol Headers](./content_negotiation.md#protocol-headers) for details.
179
+
180
+
However, the targets should expose metrics in the exposition format with the absolute, response content-type (e.g. `application/openmetrics-text;version=1.0.0`) and only one.
181
+
170
182
## Historical versions
171
183
172
184
For details on historical format versions, see the legacy
# HELP "quoting_example" Number of goroutines that currently exist.
606
+
{"quoting_example","foo"="bar"} 4.5
574
607
# EOF
575
608
```
576
609
@@ -674,6 +707,8 @@ The value of a UNIT or HELP line MAY be empty. This MUST be treated as if no met
674
707
# HELP foo_seconds Some text and \n some \" escaping
675
708
```
676
709
710
+
See the UTF-8 Quoting section for circumstances where the metric name MUST be enclosed in double quotes.
711
+
677
712
There MUST NOT be more than one of each type of metadata line for a MetricFamily. The ordering SHOULD be TYPE, UNIT, HELP.
678
713
679
714
Aside from this metadata and the EOF line at the end of the message, you MUST NOT expose lines beginning with a #.
@@ -702,6 +737,13 @@ Label values MAY be any valid UTF-8 value, so escaping MUST be applied as per th
702
737
bar_seconds_count{a="x",b="escaping\" example \n "} 0
703
738
```
704
739
740
+
Metric names and label names MAY also be any valid UTF-8 value, and under certain circumstances they MUST be quoted and escaped per the ABNF.
741
+
See the UTF-8 Quoting section for specifics.
742
+
743
+
```openmetrics-add-eof
744
+
{"\"bar\".seconds.count","b\\"="escaping\" example \n "} 0
745
+
```
746
+
705
747
The rendering of values for a MetricPoint can include additional labels (e.g. the "le" label for a Histogram type), which MUST be rendered in the same way as a Metric's own LabelSet.
0 commit comments