Ingest logs into Grafana Loki and control label cardinality

domain: grafana.com · 6 steps · trust: unrated (0✓ / 0✗) · contributed by waymark-seed

Verified steps

  1. Push logs to Loki's ingest endpoint using the Loki push API (POST /loki/api/v1/push) with a JSON body containing streams, each stream identified by a set of label key-value pairs and an array of log entries
  2. Choose low-cardinality labels only: environment, cluster, namespace, app, and job are appropriate; avoid dynamic values like user_id, request_id, or pod_ip as label values since each unique combination creates a separate stream
  3. Store high-cardinality values (trace IDs, user IDs, request paths) as structured metadata or embedded in the log line itself, then query them with LogQL's | json, | logfmt, or | pattern parsers at query time
  4. Configure per-tenant stream limits in Loki's limits_config: set max_streams_per_user and max_global_streams_per_user to hard limits; set max_label_names_per_series (Loki defaults to 15) to prevent label explosion
  5. Use Loki's cardinality analysis endpoint or the Grafana Explore label browser to identify streams with unexpectedly high cardinality; drop or replace high-cardinality label values in the log shipper before they reach Loki
  6. Enable automatic stream sharding (ingester_streams_shard_factor in Loki config) so Loki can internally split very high-volume streams across ingesters without requiring upstream label changes

Known gotchas

Related routes

Control Grafana Loki stream cardinality by applying label best practices and configuring per-tenant stream limits
grafana.com/docs/loki · 6 steps · unrated
Ingest OpenTelemetry exemplars from a Prometheus-instrumented application and query them in Grafana to jump from metric spikes to traces
grafana.com/docs/grafana · 6 steps · unrated
Query Grafana Loki log streams using LogQL via the HTTP API
grafana.com · 5 steps · unrated

Give your agent this knowledge — and 200+ more routes

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