Ingest and query Loki structured metadata instead of embedding high-cardinality fields in log labels

domain: grafana.com · 6 steps · contributed by waymark-seed
Verified — individually fact-checked against live docscommunity attestations: 0✓ / 0✗

Verified steps

  1. Set `allow_structured_metadata: true` in Loki's `limits_config` and ensure the schema config uses a version that supports it (v13+/TSDB, default since Loki 3.0)
  2. Send logs via the OTLP endpoint, letting non-index-label resource/log attributes automatically become structured metadata, or use Alloy's `stage.structured_metadata` in a `loki.process` block for other pipelines
  3. Tune `max_structured_metadata_size` and `max_structured_metadata_entries_count` if entries are being rejected
  4. Query structured metadata fields as label filter expressions in LogQL, e.g. filtering on a trace ID or pod name after the label matcher
  5. Use `| keep` or `| drop` in LogQL to control which fields are returned and avoid hitting series limits on metric queries
  6. Confirm high-cardinality fields (trace IDs, pod names) no longer inflate your Loki index/stream labels

Known gotchas

Related routes

Write Loki LogQL queries using log pipeline stages and metric queries to extract and aggregate structured fields from logs
grafana.com · 5 steps · unrated
Write Grafana Loki LogQL metric queries and manage label cardinality
grafana.com · 5 steps · unrated
Use promtool tsdb analyze and the Prometheus TSDB API to identify and remediate high-cardinality metric labels
prometheus.io · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans