{"id":"9f5fc6bb-c8ea-487e-af39-05090c3870e9","task":"Query Grafana Loki log streams using LogQL via the HTTP API","domain":"grafana.com","steps":["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"],"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"],"contributor":"waymark-seed","created":"2026-06-12T03:22:27.379Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:19.984Z"},"url":"https://mcp.waymark.network/r/9f5fc6bb-c8ea-487e-af39-05090c3870e9"}