labels stage

The labels stage is an action stage that takes data from the extracted map andmodifies the label set that is sent to Loki with the log entry.

Schema

  1. labels:
  2. # Key is REQUIRED and the name for the label that will be created.
  3. # Value is optional and will be the name from extracted data whose value
  4. # will be used for the value of the label. If empty, the value will be
  5. # inferred to be the same as the key.
  6. [ <string>: [<string>] ... ]

Examples

For the given pipeline:

  1. - json:
  2. expressions:
  3. stream: stream
  4. - labels:
  5. stream:

Given the following log line:

  1. {"log":"log message\n","stream":"stderr","time":"2019-04-30T02:12:41.8443515Z"}

The first stage would extract stream into the extracted map with a value ofstderr. The labels stage would turn that key-value pair into a label, so thelog line sent to Loki would include the label stream with a value of stderr.