Prometheus discovers, scrapes, and processes different types of labeled objects. The most obvious ones are scrape targets and time series samples, but alerts have labels as well:
Often it is useful to be able to manipulate or filter these objects based on their label values. For example, we might want to:
- Only monitor certain targets that have a specific service discovery annotation that indicates that they should be scraped.
- Add an HTTP query parameter to the scrape request for a target.
- Only store a filtered subset of the samples scraped from a given target.
- Remove a replica label from alerts sent to the Alertmanager (so that identical alerts sent from a high availability Prometheus can be deduplicated in the Alertmanager).
- Combine two label values of a scraped series into a single label (or vice versa).
Relabeling is a concept that allows the Prometheus administrator to configure these kinds of transformation and filtering rules.