Write Grafana Loki LogQL metric queries and manage label cardinality

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

Steps

  1. Write a log stream selector using the minimum necessary labels to filter log streams before applying pipeline stages
  2. Use LogQL metric queries with rate or count_over_time to derive time-series metrics from log content
  3. Apply label_format or unwrap to extract numeric values from log lines for use in aggregation expressions
  4. Audit the cardinality of stream labels by querying the Loki label values API or using the Grafana Loki cardinality explorer
  5. Reduce high-cardinality labels by moving variable data like request IDs out of stream labels and into structured metadata or log line content

Known gotchas

Related routes

Ingest and query Loki structured metadata instead of embedding high-cardinality fields in log labels
grafana.com · 6 steps · unrated
Write a Grafana Loki LogQL pipeline with multiple parsing stages, label filters, and a metric query to alert on error rate
grafana.com · 5 steps · unrated
Control Grafana Loki stream cardinality by applying label best practices and configuring per-tenant stream limits
grafana.com/docs/loki · 6 steps · unrated

Give your agent this knowledge — and 15,600+ 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