CQL cheat sheet
Common tasks as copyable CQL, with the closest construct in LogQL, Splunk SPL and CloudWatch Logs Insights.
Verified against v1.0.0-rc.1 · sources
On this page
The time range is never in the query. Set it with the time picker. Full grammar: CQL reference.
Filter by level
Filterlevel=errorIn LogQL / SPL / CloudWatch Insights
- LogQL:
{app="x"} | level="error" - SPL:
level=error - CloudWatch:
filter level = "error"
Substring or regex
Searchmsg ~ "time.*out"In LogQL / SPL / CloudWatch Insights
- LogQL:
|~ "time.*out" - SPL:
| regex _raw="time.*out" - CloudWatch:
filter @message like /time.*out/
Free text, case-exact phrase
Searchc"OOMKilled"Plain words and quoted phrases ignore case. The c prefix matches case exactly.
Several values, exclude a host
Filterservice=pay-api level IN (error,fatal) NOT host=app2Count by field
Statsstats count() by serviceIn LogQL / SPL / CloudWatch Insights
- LogQL:
sum by (service) (count_over_time(...)) - SPL:
stats count by service - CloudWatch:
stats count(*) by service
95th percentile
Statsstats p95(duration_ms)In LogQL / SPL / CloudWatch Insights
- LogQL:
quantile_over_time(0.95, ...) - SPL:
stats p95(duration_ms) - CloudWatch:
stats pct(duration_ms, 95)
Distinct count
Statsstats dc(user_tok)In LogQL / SPL / CloudWatch Insights
- LogQL: n/a
- SPL:
stats dc(user_tok) - CloudWatch:
stats count_distinct(user_tok)
Time buckets
Timetimechart span=5m count()In LogQL / SPL / CloudWatch Insights
- LogQL:
count_over_time(...[5m]) - SPL:
timechart span=5m count - CloudWatch:
stats count(*) by bin(5m)
Top N
Top and raretop 5 serviceIn LogQL / SPL / CloudWatch Insights
- LogQL:
topk(5, ...) - SPL:
top limit=5 service - CloudWatch:
stats count(*) by service | sort ... | limit 5
Rare N
Top and rarerare 5 serviceIn LogQL / SPL / CloudWatch Insights
- LogQL:
bottomk(5, ...) - SPL:
rare limit=5 service - CloudWatch: no direct form
Sort descending
Shapestats count() by service | sort -countIn LogQL / SPL / CloudWatch Insights
- LogQL: n/a
- SPL:
sort - count - CloudWatch:
sort count desc
Limit rows
Shapelimit 50In LogQL / SPL / CloudWatch Insights
- LogQL: n/a
- SPL:
head 50 - CloudWatch:
limit 50
Choose fields
Shapefields ts, msgIn LogQL / SPL / CloudWatch Insights
- LogQL: n/a
- SPL:
table ts, msg - CloudWatch:
fields @timestamp, @message
Find delivery gaps
Searchsource=gapsGaps found by the reconciler. source= must be the first term.
Not in CQL#
OpenTelemetry field aliases#
Both names work in queries and saved queries (source=events): severity_text→level, http.response.status_code / http.status_code→http_status, url.path→http_path, service.name→service, host.name→host, enduser.id→user_tok. trace_id, span_id, severity_number are attribute fields. See Ingest overview.