LogQL Cheatsheet

Top patterns.

Overview

LogQL is Grafana Loki’s query language. Five primitive surfaces cover almost every investigation: label selector to narrow scope by indexed labels, line filter for content matches, parser stages for structured-field extraction, metric queries that turn log streams into time series, and aggregations for cross-stream analysis.

The approach

Five idioms cover most LogQL use. Memorising them moves the team from full-text scrolling to surgical log investigation.

Why this compounds

Each LogQL query teaches the data model. The team’s investigation speed deepens; label-design improves alongside query patterns; Loki cost stays controlled because queries narrow on indexed labels first.