Write a log stream selector using the minimum necessary labels to filter log streams before applying pipeline stages
Use LogQL metric queries with rate or count_over_time to derive time-series metrics from log content
Apply label_format or unwrap to extract numeric values from log lines for use in aggregation expressions
Audit the cardinality of stream labels by querying the Loki label values API or using the Grafana Loki cardinality explorer
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
Each unique combination of stream label values creates a distinct log stream; high-cardinality labels like user_id or request_id cause excessive stream creation and degrade query and ingest performance
Loki is not designed for full-text search across all streams simultaneously; always include high-selectivity stream label filters to avoid full-scan queries that time out
Metric queries over long time ranges with high-cardinality streams can exhaust Loki's query memory limits; use recording rules or pre-aggregation for frequently accessed metrics
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