Relabeling Rule Fields

Relabeling rules generally have the following configuration fields, but for each type of action (relabeling rule type), only a subset of these fields are used:

action: <relabel action>
source_labels: [<source label name list>]
separator: <source labels separator>
target_label: <target label>
regex: <regular expression>
modulus: <modulus value>
replacement: <replacement string>

The fields have the following meaning:

  • action: The desired relabeling action to execute. Defaults to replace. Possible actions (explained in the following sections) are:
    • replace
    • keep
    • drop
    • hashmod
    • labelmap
    • labeldrop
    • labelkeep
    • keepequal
    • dropequal
    • lowercase
    • uppercase
  • source_labels: A list of label names that are concatenated using the configured separator string and matched against the provided regular expression in the regex field.
  • separator: A string with which to separate source labels when concatenating them. Defaults to ";".
  • target_label: The name of the label that should be overwritten when using the replace or hashmod relabel actions.
  • regex: The regular expression to match against the concatenated source labels. Defaults to "(.*)", matching any source labels.
  • modulus: The modulus to take of the hash of the concatenated source labels. Useful for horizontal sharding of Prometheus setups.
  • replacement: A replacement string that is written to the target_label label for replace relabel actions. It can refer to regular expression capture groups that were captured by regex.