Menu
Open source
structured_metadata
Warning: Structured metadata is an experimental feature and is subject to change in future releases of Grafana Loki.
The 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 theallow_structured_metadata
per tenant configuration (in thelimits_config
).
Schema
yaml
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>] ... ]
Examples
For the given pipeline:
yaml
- json:
expressions:
stream: stream
traceID: traceID
- labels:
stream:
- structured-metadata:
traceID:
Given the following log line:
{"log":"log message\n","stream":"stderr","traceID":"0242ac120002",time":"2019-04-30T02:12:41.8443515Z"}
The first stage would extract stream
with a value of stderr
and traceID
with a value of 0242ac120002
into
the extracted data set. The labels
stage would turn that stream
and stderr
key-value pair into a stream label.
The structured-metadata
stage would attach the traceID
and 0242ac120002
key-value pair as a structured metadata to the log line.
Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:

Getting started with logging and Grafana Loki
See a demo of the updated features in Loki, and how to create metrics from logs and alert on your logs with powerful Prometheus-style alerting rules.

Essential Grafana Loki configuration settings
This webinar focuses on Grafana Loki configuration including agents Promtail and Docker; the Loki server; and Loki storage for popular backends.

Scaling and securing your logs with Grafana Loki
This webinar covers the challenges of scaling and securing logs, and how Grafana Enterprise Logs powered by Grafana Loki can help, cost-effectively.