Lower-Casing and Upper-Casing

Sometimes you may want to change the text case of a label value to make it match another label value's case, so that you can compare them. For example, you may want to match a label value that is in all uppercase letters with another label value that is in all lowercase letters. The lowercase and uppercase relabeling actions allow you to do this.

Rule structure

A lowercase relabeling rule has the following structure:

action: lowercase
source_labels: [<source label name list>]
target_label: <target label>

This action performs the following steps, in sequence:

  1. It concatenates the values of the labels listed in source_labels using the provided separator value.
  2. It lower-cases that concatenated value and stores it in the label provided as target_label.

The uppercase action works like lowercase, but upper-cases the output value instead of lower-casing it.

Use case examples

Let's look at an example use case for the lowercase action.

Lower-casing a label value

Imagine you have two exporters providing you with machine-level metrics, with one providing the machine's hostname in all uppercase letters in a host label, and the other providing the machine's hostname in all lowercase letters in a similar label. You want to be able to compare the two values, but you can't do that if they are in different cases. You can use the lowercase action to lower-case the value of the upper-cased label, so that you can compare them:

- action: lowercase
  source_labels: [host]
  target_label: host