Relabeling Overview

Relabeling is implemented as a series of transformation steps that you can apply in different sections of the Prometheus configuration file to filter or modify a list of labeled objects. You can apply relabeling to the following types of labeled objects:

  • Discovered scrape targets (relabel_configs section in a scrape_config section).
  • Individual samples from scrapes (metric_relabel_configs section in a scrape_config section).
  • Alerts sent to the Alertmanager (alert_relabel_configs section in the alertmanager_config section).
  • Samples written to remote storage systems (write_relabel_configs section in the remote_write section).

Relabeling in the Prometheus architecture

All of these different relabeling configuration sections are of the same type relabel_config.

Each relabeling configuration section consists of a list of rules that are applied in sequence to each labeled object:

Relabeling flow

For example, a relabeling rule may keep or drop an object based on a regular expression match, may modify its labels, or may map a whole set of labels to another set. Once a relabeling step decides to drop a labeled object, no further relabeling steps are executed for this object and it is deleted from the output list (for example, for a target, this would mean it will not be scraped).