Stream selectors
Every LogQL query starts with a stream selector inside curly braces. You must always specify the__bucket__ label to select the log bucket:
sp_serialfor serial logs of Compute virtual machinessp_mlflowfor Managed Service for MLflow logssp_postgresfor Managed Service for PostgreSQL® logssp_cloudappsfor Nebius Applications logsdefaultfor your own logs
| Operator | Description | Example |
|---|---|---|
= | Exact match | {__bucket__="sp_postgres", container="pgbouncer"} |
!= | Negation | {__bucket__="sp_postgres", container!="pgbouncer"} |
=~ | Regex match | {__bucket__="sp_postgres", container=~"pg.*"} |
!~ | Regex negation | {__bucket__="sp_postgres", container!~"pgbouncer|odyssey"} |
Line filters
After the stream selector, chain line filters to search the log message text:| Operator | Description | Example |
|---|---|---|
|= | Line contains text | {...} |= "error" |
!= | Line doesn’t contain text | {...} != "healthcheck" |
|~ | Line matches regex | {...} |~ "status=5\\d+" |
!~ | Line doesn’t match regex | {...} !~ "GET /health" |
Examples
Basic log search
Find deadlocks in PostgreSQL® logs:Filter by log level
Search with regex
Find HTTP 5xx status codes:Find slow requests
Limitations
Logging’s LogQL implementation has the following limitations:-
You must always include
__bucket__in the stream selector. Queries without it return no entries. -
The
stepvalue (interval between points) must be smaller than therangevalue (the interval over which aggregation is performed). - Alerts on aggregated metrics values are not supported.
-
The entries with non-empty
__error__value are ignored. As a result, filtering by error is not possible. -
The following functions are not supported:
bytes_rate,bytes_over_timefunctionsabsent_over_time(because alerts on aggregated metrics values are not supported)topk,bottomkwithout aggregation by label (because no entries are shown when labels are empty)sort,sort_descaggregationswithoutaggregation clausesvectorfunctionapprox_topkaggregation
Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.