Control Grafana Loki stream cardinality by applying label best practices and configuring per-tenant stream limits

domain: grafana.com/docs/loki · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Audit your current label set by querying active streams: use the Loki label API or a LogQL query like count by (job) ({}) to enumerate all active stream combinations
  2. Remove high-cardinality labels (trace IDs, user IDs, request IDs, HTTP paths) from the indexed label set in your log shipper (Promtail, Alloy, or Fluent Bit) configuration
  3. For searchable high-cardinality values, use Loki structured metadata (via the push API or Alloy's loki.write with labels_from_metadata) which does not create index streams
  4. Configure per-tenant limits in Loki's limits_config: set max_streams_per_user and max_label_names_per_series to guard against cardinality explosions; avoid increasing max_label_names_per_series beyond the default of 15
  5. Alert on stream growth by monitoring the loki_ingester_memory_streams metric and setting an alert when it exceeds a safe threshold for your cluster size
  6. Use LogQL label filter expressions (| label_format, | drop) in queries to handle log lines where label cleanup was missed at the shipper level

Known gotchas

Related routes

Configure Grafana Loki per-tenant ingestion and stream rate limits
grafana.com · 5 steps · unrated
Write Grafana Loki LogQL metric queries and manage label cardinality
grafana.com · 5 steps · unrated
Ingest logs into Grafana Loki and control label cardinality
grafana.com · 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