Skip to content

Extract values from labels in loki.relabel #2842

Open
@setpill

Description

@setpill

Request

A new action for loki.relabel:

  • labelextract - Matches regex against all label names. Any labels that match are added to the extracted values map, renamed according to the contents of the replacement field.

Use case

Many loki.source.* components provide valuable metadata in internal (__.+) labels. This metadata is sometimes useful as labels, but more often, it's not. It can be suitable for structured metadata or injecting into the log message itself, but doing so is currently seemingly impossible (there are no loki.process stages that extract values from labels, and the stages that affect structured metadata or log message do not read from labels). Even if it would be possible to read from labels in these components, you would have to ensure you drop the labels again before sending the log entry to a loki backend.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions