Identify the Loki base URL and any required authentication (basic auth or Bearer token for Grafana Cloud Loki)
For instant log queries GET '/loki/api/v1/query' with parameters 'query' (URL-encoded LogQL expression), 'limit' (max lines), and 'time' (Unix nanosecond timestamp or RFC3339)
For range log queries GET '/loki/api/v1/query_range' with 'query', 'start' and 'end' (Unix nanoseconds or RFC3339), 'limit', and 'step' (for metric queries)
Use stream selectors in LogQL to narrow results: '{app="myapp", env="prod"}' followed by filter expressions like '|= "ERROR"' or '| json | level="error"' for structured logs
For metric queries (log rate, count over time) append a metric expression like '| rate({app="myapp"}[5m])' and use query_range with a step interval; results return in Prometheus-compatible matrix format
Known gotchas
Loki uses label-based indexing; querying without stream selector labels (or with very broad selectors) results in full log store scans, causing high latency or query timeout errors
Timestamps in Loki are nanosecond epoch integers, not milliseconds; passing millisecond timestamps causes queries to look at the wrong time window without an explicit error
The default query timeout and result limit are configurable on the Loki server; client-side queries that exceed server limits return a 429 or truncated result — reduce time range or add more specific stream selectors
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