When to use structured metadata in Loki
Your stream count is climbing because high-cardinality fields such as trace IDs, pod names or user IDs have been promoted to index labels, and you need somewhere to keep those values queryable without indexing them. Structured metadata is that place. It attaches key-value pairs to individual log lines, so each value is stored with the entry and can be filtered at query time, but it does not create a new stream or add an entry to the label index. Every distinct label combination in Loki produces a stream, so moving a value out of labels is often the fastest way to bring the stream count back under control.
Use structured metadata when a field is unique or nearly unique per request, per pod or per user, and you still need to filter on it during investigations. Keep static, bounded values such as cluster, namespace and environment as labels, because those drive how Loki selects streams and chunks. Use a line filter when the value is only needed as text inside the message and you do not need it as a field. Structured metadata sits between the two: it is queryable like a label but stored like a field. Before you move anything, list the candidate fields per tenant, confirm which ones your team actually filters on, and check with your Loki version that structured metadata is available to you.
Structured metadata has prerequisites that decide whether it works at all. It was added in chunk format V4, requires schema version 13 or later, and needs the TSDB index. If your cluster runs an older schema or index store, plan the schema and index upgrade before you change your log shipper configuration, since the existing data will not gain the new fields. Ask your platform team to confirm the schema config and index type in the running cluster, and record the owners who approve that change. The Loki documentation on structured metadata lists these requirements and should be your reference for the version you deploy.
Which field goes where: labels, structured metadata or line content
This table compares index labels, structured metadata and line content across cardinality, query cost, index impact and typical fields. Read each row as a placement decision: the closer a field's values are to unique per line, the further it should sit from the index. The main takeaway is that the 15 index label default is a reason to move high-cardinality fields out of labels.
| Field placement | Best for | Index impact | Typical fields and trade-offs |
|---|---|---|---|
| Index labels | Low, bounded values used to select streams | Each unique combination creates a stream in the index | cluster, namespace, environment, service_name. Keep values few and stable. |
| Structured metadata | High-cardinality values you want to filter on without indexing them | Stored with the log line, not in the stream index | trace_id, span_id, pod name, user ID. Requires chunk format V4, schema v13 or later and TSDB. |
| Parsed fields | Values pulled from the line at query time with a parser | No index entry; cost is paid when the query runs | Status codes, request paths, JSON keys. Useful when the field is rarely filtered on. |
| Line content | Free text searched with line filters | No index entry; scanned at query time | Stack traces, error messages, payload fragments. Substring search scans matching chunks. |
| Cardinality | Number of distinct values a field can take | Drives stream count when the field is a label | Pod names and trace IDs grow without limit, so they belong in structured metadata or content. |
| Default index label limit | Loki's default of 15 index labels per stream | Exceeding it makes the label set harder to keep healthy | Move fields beyond the core set into structured metadata, so the label budget goes to selectors. |
| Query cost | How expensive filtering on the field is | Labels narrow the scan first; metadata filters apply to stored chunks | Filter on labels first, then structured metadata, then line filters. Confirm the order against your Loki version. |
How to enable and verify structured metadata
This sequence takes a Loki cluster from its current index and schema settings to a state where high-cardinality fields arrive as structured metadata and can be returned by a query. Each step ends with a check so you know it is complete before moving on.
Confirm the Loki version and TSDB index
Start by checking which Loki version is running and which index store the cluster uses. Structured metadata requires the TSDB index, and the feature is tied to chunk format V4, so the cluster must be on a version that supports that chunk format and must not rely on the deprecated index stores such as DynamoDB, Bigtable or Cassandra. Confirm the version against the Loki releases page and the running binary or Helm chart values. The step is done when the running version is recorded and the active index type reads as TSDB in the schema configuration.
Set schema version 13 for the new period
Open the
schema_configblock and add a period that uses schema versionv13with the TSDB index, with a start date at or after the point where the change takes effect. Existing data stays under its old period, so the new period only applies to logs written from its start date onward. Coordinate the start date with the team that owns the storage configuration, because a poorly chosen date can leave a gap or overlap between periods. The step is done when the configuration validates and Loki starts with the new period listed in its configuration output.Restart and confirm the new schema is active
Roll the Loki components so every ingester and querier reads the updated schema, then confirm the active configuration through the configuration endpoint or the logs from each component. Mixed configurations across replicas can cause writes and reads to disagree, so check every replica, not only one pod or host. The step is done when all components report the same schema period and no startup errors refer to the schema or index type.
Decide which fields become structured metadata
List the high-cardinality fields you want to keep out of the index, such as trace IDs, span IDs, pod names or user IDs, and confirm that each one is not already used as an index label. Remove any of these from the label set in the shipper configuration so they are not indexed twice. Record the chosen field names, since the shipper and any query examples will refer to them by exact name. The step is done when the field list is agreed and none of the fields appear in your label set.
Send the fields as structured metadata from the shipper
Configure the shipper, which is typically Grafana Alloy, an OpenTelemetry Collector or another supported client, so the chosen fields travel with each log line as structured metadata rather than as labels. Check the shipper documentation for the exact setting that maps a field to structured metadata, and confirm it against your shipper version. Restart the shipper and send a test line that contains a known value for each field. The step is done when the shipper reports no rejected or dropped entries for those fields in its own logs or metrics.
Verify the fields with a query
Run a LogQL query in Grafana or the command line that selects the test stream and filters on the known value of a structured metadata field, then check that the expected log lines return. Also open one returned line in Grafana's log details view to confirm the field appears as structured metadata and not as an index label. Repeat with a second field to confirm the setup works across the set. The step is done when the test query returns the expected lines and the fields show as structured metadata in the results.
Confirm the stream count and document the setup
Check that the number of active streams has not grown after the change, since a successful move of fields out of labels should keep stream counts stable. Record the schema period, the field list, the shipper configuration and the verification query, so the team can repeat the check after upgrades. Ask your Loki administrator to confirm that the per-tenant limits for structured metadata, if they differ from defaults, match the field volume you expect. The step is done when the stream count is recorded as stable and the configuration and test query are stored with your runbook.
How a log line carries its structured metadata
The path starts at the agent, which ships each log line with its stream labels and any extra fields. The Loki distributor and ingester then split the line in two: stream labels become index entries in the TSDB index, while structured metadata stays attached to the log line inside the chunk in object storage. Check that high-cardinality fields like trace IDs sit in the metadata part, not the labels, before you query them.
Indexed labels go to the TSDB index; structured metadata stays with the chunk.
Querying structured metadata in LogQL
Structured metadata is queried alongside stream labels, so a single LogQL selector can combine a bounded index label such as namespace or cluster with a field that lives on the log line. The stream selector stays in braces and only narrows the streams Loki reads. Fields attached as structured metadata can then be filtered after the selector, using a label filter expression that names the field, for example {namespace="payments"} | trace_id="<value>". Your exact syntax depends on the field name and how your pipeline attached it, so confirm the form in the Loki structured metadata documentation before you write queries for teams to reuse. Keep the stream selector as selective as possible, because structured metadata filters do not narrow which streams are read.
The cost question is where people get misled. A filter on a structured metadata field can avoid scanning every line in the selected streams, which a line filter that searches the message text cannot do. A line filter has to read the content of each candidate line, while the metadata value is stored alongside the chunk and is not part of the line text. That advantage applies to the specific case where the value is a field you attached as metadata and the query compares it directly. It does not apply when the same value only appears inside the message body, and it does not make an unselective stream selector cheap. Run the same query both ways on a representative time range, compare the bytes and lines processed in the query statistics, and keep the faster form only where the numbers support it.
To confirm the field is working, run a query that filters on a known value and open the results in Grafana Explore. Check that the structured metadata field appears in the parsed fields or detected fields for the returned lines, and that the value matches what the application wrote. If the field is missing, check that the pipeline sent it as structured metadata rather than as a stream label or as text in the message, and that the cluster meets the schema and index requirements described in the structured metadata documentation. Record the query text, the time range and the statistics for each test so the team can rerun them after a Loki upgrade or a change to the log shipper.
What bloom acceleration does for structured metadata queries
Structured metadata values are not indexed, so a query on them can force Loki to read more chunks than it needs. Bloom acceleration is the mechanism meant to narrow that set. The cards below cover what it does, what it depends on and what to confirm in your release before you plan queries around it.
Why unindexed values need help
Labels narrow a query through the index, but structured metadata sits inside chunks and is not indexed. A query that filters on a trace ID or pod name therefore starts from a wider set of chunks than a label query would. Bloom filters exist to reduce that candidate set before Loki reads chunk contents. Plan your queries so that a label or stream selector still bounds the search, and treat bloom filtering as a way to narrow what remains.
Structured metadata docsWhat a bloom filter tells the query
A bloom filter is a probabilistic structure that answers whether a value might be present in a chunk. A negative answer is definitive, so Loki can skip that chunk, while a positive answer means the chunk still has to be read and checked. The result is fewer chunks scanned, not a change to query results. Expect false positives, which means some chunks are read that contain no match.
Dependence on schema and index
Bloom acceleration builds on the same foundations as structured metadata. Structured metadata requires schema version 13 or later and the TSDB index, so a cluster still on an older schema or index store cannot use this path. Confirm the schema configuration in your Loki release before you assume any filtering benefit. Migrating a cluster to meet these requirements is a separate planning task.
Bloom configuration to confirm
Bloom support, the components that build and serve bloom data, and the settings that control them are features you must verify in the Loki release you run. Check the configuration reference for your exact version, including how bloom building is enabled and where its data is stored. Do not copy settings from older examples or blog posts, because option names and defaults change between releases.
Loki storage docsTesting query impact before rollout
Because bloom filtering changes which chunks are read, it can change query latency and cost in ways that depend on your data. Run representative searches on structured metadata in a non-production cluster with bloom acceleration on and off, and compare the results and resource use. Record the Loki version and configuration with each test so the findings stay valid after upgrades.
Version requirements and upgrades
Bloom behavior can differ between Loki releases, so the version you run is a deciding factor. Review the release notes for the version you plan to adopt and check whether bloom features are stable, experimental or changed in that line. Include bloom settings in your upgrade plan, and retest structured metadata queries after every minor or major upgrade.
Loki releases on GitHubQuestions teams ask before enabling structured metadata
Can our team enable structured metadata ourselves?
Yes, if your team already runs Loki and includes people who can read schema configuration and upgrade notes. The change is mostly configuration and migration planning. Structured metadata requires schema version 13 or later, the TSDB index, and chunk format V4, so your current setup must meet those conditions first. Teams with no Loki operating history, or with many shippers and dashboards to coordinate, usually find the coordination harder than the configuration edit. A partner is most useful for the design review, the migration sequence and the verification steps. Before you change anything, confirm the exact configuration keys against the Loki structured metadata documentation for the version you run.
What does enabling structured metadata cost?
Loki is open source under AGPLv3, so the cost is labor, infrastructure and time rather than a license fee for the feature. The main components are internal engineer time for planning, configuration and rollout, any partner fee set by written scope, and storage and compute changes that you must measure in your own environment. Design, migration and verification are one-time work. Storage growth, retention and query load recur after the change. Ask any partner for a quote that lists each phase, who performs it, the environment sizes assumed, and which items are excluded, such as shipper rework or dashboard updates.
How long does a structured metadata rollout take?
Duration depends mainly on the deployment mode, the number of clusters, the number of log shippers and how many teams query the affected data. No duration has been supplied for this work, so treat any figure you receive as something to confirm. The Loki documentation describes monolithic, simple scalable and microservices modes, and monolithic mode is documented for up to about 20 GB of logs per day, which is a sizing boundary rather than a timeline. Simple scalable mode is being deprecated and will be removed in Loki 4.0, so an environment on that mode may need a deployment move in the same plan. Ask for a schedule per environment with its dependencies listed.
Which parts of the logging pipeline must change?
The schema and index change is on the Loki side, but log shippers also change because fields that were labels must reach Loki as metadata. Promtail reached end of life on March 2, 2026, with no further updates or commercial support, so if you still run it, plan the move to Grafana Alloy as part of this work. Fluent Bit, Fluentd, the Docker logging driver and OpenTelemetry over HTTP are other supported ingestion paths, and each has its own field mapping to check. Dashboards, alert rules and saved queries that reference the moved fields also need updates. Confirm each shipper's mapping against its own documentation.
Will our analysts need retraining to query structured metadata?
Most teams need some retraining, because queries that filter on high-cardinality values change shape. Values that were stream labels are matched through the stream selector, while structured metadata fields are filtered in the query after the selector, and analysts who relied on label matching need to learn that difference. Plan short training on the query patterns your team uses most, update runbooks, and maintain a set of tested example queries for incident response. Teams that work mainly through Grafana Explore usually need less change than teams that write queries by hand. Confirm the query syntax against the structured metadata documentation for your Loki version.
How does retention and storage change after the switch?
Retention is disabled by default, so Loki keeps logs indefinitely until retention_enabled is set. The compactor can apply retention globally, per tenant or per stream selector, and each stream rule must be at least 24 hours. Structured metadata changes what is written to the index and chunks, so measure storage in a pilot before and after the change instead of assuming a result. Set retention before migration so older and newer data follow the same policy, and have your compliance team confirm the deletion behavior. Amazon S3, Google Cloud Storage and Azure Blob Storage are the recommended production object stores, and the documentation notes that MinIO and the local filesystem are not typically recommended for production.
Does structured metadata need a separate authentication setup?
Loki has no built-in authentication layer, so the security boundary sits in front of it. The documentation says to run an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium. When auth_enabled is true, Loki identifies tenants by the X-Scope-OrgID header on every request, so the proxy must set or restrict that header correctly. Structured metadata does not change this model, but it adds fields such as trace IDs and pod names that may carry sensitive detail, so review what reaches metadata before you enable it. Ask your security team to test the proxy and tenant isolation.
How DeployOpen works on this
DeployOpen plans structured metadata work for Loki as a fixed-scope engagement, starting from the fields your teams need to query and the label set you already run. The work is built and tested in your own infrastructure, then handed over with documentation your operators can maintain.
How we scope
- Inventory the high-cardinality fields your teams filter on, such as trace IDs, pod names and request IDs, and decide which stay as labels.
- Confirm the Loki version, schema version and TSDB index in use before any change to ingestion is planned.
- Record the scope, deliverables and timeline in writing before work starts, so the boundaries of the change are agreed.
How we build
- Set up schema v13 and the TSDB index in a non-production environment, then verify that structured metadata is stored with the chunk format.
- Configure the shipper, such as Grafana Alloy, to send chosen fields as structured metadata while keeping the index limited to bounded labels.
- Test LogQL queries that filter on structured metadata, and measure ingestion and query behavior against your expected volumes.
How we hand over
- Deliver a written label and metadata map listing each field, its storage location and the teams that query it.
- Document the configuration changes, rollback steps and the schema and index settings your operators must keep consistent.
- Walk your operators through query examples and the checks they will run to confirm structured metadata keeps working.
How we support
- Review new log sources against the label and metadata map before they reach production, so cardinality does not drift.
- Provide retainer-based support for upgrades, configuration reviews and troubleshooting after the handover is complete.
- Re-test queries and ingestion after Loki upgrades or shipper changes, and update the documentation to match the running setup.

