OQL Cookbook
These examples stay within the OQL features implemented by the current storage backends.
Discover available telemetry
List metric names:
SHOW metricsList known attributes for each signal:
SHOW logs attributesSHOW metrics attributesSHOW traces attributesSHOW spans attributesList observed values for a filterable attribute:
SHOW logs attribute_values('service.name') | RANGE 1hSHOW traces attribute_values('service.name') | RANGE 1hLogs
Find the latest errors from one service:
GET logs| RANGE 30m| FILTER severity = 'ERROR' AND service.name = 'checkout-api'| SORT timestamp DESC| LIMIT 50Search for timeout-related log messages, case-insensitively:
GET logs| RANGE 1h| FILTER message ILIKE '%timeout%'| SORT timestamp DESC| LIMIT 100Count errors by service:
GET logs| RANGE 6h| FILTER severity = 'ERROR'| STATS count() -> error_count| BY service.name| SORT error_count DESC| LIMIT 20Count noisy HTTP status codes:
GET logs| RANGE 1h| FILTER severity IN ('ERROR', 'WARN') AND http.status_code >= 400| STATS count() -> count| BY http.status_code| SORT count DESCMetrics
Plot metric point volume by metric name:
GET metrics| RANGE 3h| STATS count() -> points| BY name EVERY 5m| SORT time_bucket ASCInspect raw samples for one metric:
GET metrics| RANGE 1h| FILTER name = 'system.cpu.time'| PICK timestamp, name, type, value| SORT timestamp ASC| LIMIT 200Average a metric by host:
GET metrics| RANGE 6h| FILTER name = 'system.cpu.usage'| STATS avg(value) -> avg_cpu| BY host.name EVERY 5m| SORT time_bucket ASCTraces and Spans
Find the slowest trace summaries:
GET traces| RANGE 1h| FILTER trace_duration > 500ms| SORT trace_duration DESC| LIMIT 20Count trace roots by name:
GET traces| RANGE 24h| STATS count() -> count| BY name EVERY 10m| SORT time_bucket ASCList spans for one trace:
GET spans| RANGE 1h| FILTER trace_id = '00112233445566778899aabbccddeeff'| PICK trace_id, id, parent_span_id, name, start_timestamp, duration| SORT start_timestamp ASCFind slow server spans with HTTP failures:
GET spans| RANGE 1h| FILTER span_kind = 'SERVER' AND duration > 250ms AND http.status_code >= 500| PICK trace_id, name, duration, http.route, http.status_code| SORT duration DESC| LIMIT 25Count error spans by route:
GET spans| RANGE 2h| FILTER status_code = 'ERROR' AND http.route IS NOT NULL| STATS count() -> error_spans| BY http.route| SORT error_spans DESC| LIMIT 20