LogchefQL syntax ↗

LogchefQL Playground

Write one query. See what ClickHouse, VictoriaLogs and Grafana Loki receive.

SQL

ClickHouse

SELECT *
FROM logs.events
WHERE `timestamp` BETWEEN toDateTime('2026-01-01 00:00:00', 'UTC') AND toDateTime('2026-01-01 01:00:00', 'UTC')
  AND ((`level` = 'error') AND (`status` >= 500))
ORDER BY `timestamp` DESC
LIMIT 100
LogsQL

VictoriaLogs

(level:="error") AND (status:>=500)
LogQL

Grafana Loki

{service_name=~".+", level="error"} | json | drop __error__, __error_details__ | status>=500 | __error__=""
Precompiled exampleRun it for real on demo.logchef.app ↗
Which source settings does the compiler use?

ClickHouse reads logs.events over the first hour of January 1, 2026 (UTC), with timestamp as the time column and a 100-row limit. VictoriaLogs uses _time. Loki parses JSON and treats service_name and level as stream labels. The default time bucket is five minutes. Editing compiles locally and does not run a database query.

Worked example: count errors by service

level="error" | count() by service

ClickHouse
SELECT `service` AS `service`, count() AS `count`
FROM logs.events
WHERE `timestamp` BETWEEN toDateTime('2026-01-01 00:00:00', 'UTC') AND toDateTime('2026-01-01 01:00:00', 'UTC')
  AND (`level` = 'error')
GROUP BY `service`
ORDER BY `count` DESC, `service` ASC
LIMIT 100
VictoriaLogs
level:="error" | stats by (service) count() as __lc_v0 | sort by (__lc_v0 desc, service)
Grafana Loki
aggregations are not supported for this source type