This is documentation for the next version of Loki. For the latest stable release, go to the latest version.
Warning: Structured metadata is an experimental feature and is subject to change in future releases of Grafana Loki.
structured_metadata stage is an action stage that takes data from the extracted map and
modifies the structured metadata that is sent to Loki with the log entry.
Warning: Structured metadata will be rejected by Loki unless you enable the
allow_structured_metadataper tenant configuration (in the
structured_metadata: # Key is REQUIRED and the name for the label of structured metadata that will be created. # Value is optional and will be the name from extracted data whose value # will be used for the value of the label. If empty, the value will be # inferred to be the same as the key. [ <string>: [<string>] ... ]
Parse from log entry
For the given pipeline:
- json: expressions: stream: stream traceID: traceID - labels: stream: - structured_metadata: traceID:
Given the following log line:
The first stage would extract
stream with a value of
traceID with a value of
the extracted data set. The
labels stage would turn that
stderr key-value pair into a stream label.
structured_metadata stage would attach the
0242ac120002 key-value pair as a structured metadata to the log line.
Parse from service discovery labels
For the configuration below, you can use labels from
relabel_configs to use as
pipeline_stages: - structured_metadata: pod_uid: pod_host_ip: relabel_configs: - action: replace source_labels: - __meta_kubernetes_pod_uid target_label: pod_uid - action: replace source_labels: - __meta_kubernetes_pod_host_ip target_label: pod_host_ip
Given the following discovered labels below with a log line
|- Discovered label||- Value||- Target label|
structured_metadata stage would turn the discovered labels
pod_host_ip into key-value pairs as structured metadata for the log line
sample log and
exclude them from creating high-cardinality streams.