Appendix 3.B Query Language Reference

An index of the language, and of where each construct is valid. The normative definitions are in §3.18 to §3.27; nothing here adds a rule.

3.B.1 Shape #

EVENTS [type_pattern]                             [clauses…]
LOGS   [FROM o[, o…]] [ERROR ONLY] [CONTAINING s] [clauses…]
METRIC name[label_selector] [transform] [aggregation] [clauses…]

3.B.2 Clause validity #

ClauseEVENTSLOGSMETRICSection
SINCE / UNTILyesyesyes§3.19
WHEREyesyesyes§3.20
WHERE METRICyesyesno§3.26
WHERE EVENT … EXISTSnoyesyes§3.26
WHERE LOG … EXISTSyesnoyes§3.26
SORTyesyesyes§3.21
TAKE / SKIPyesyesyes§3.18
SELECTnon-aggregating onlynon-aggregating onlyno§3.22
COUNT BY / TOP N BYyesyesno§3.23
DISTINCTyesyesno§3.23
GROUP + functionyesyesno§3.23
STREAMyesyesno§3.27
ERROR ONLY / CONTAININGnoyesno§3.24
INDEXyesnono§3.23

WHERE and SELECT are the only repeatable clauses (§3.18).

3.B.3 Combinations that are rejected #

CombinationRejected atSection
SELECT with COUNT BY, TOP N BY, DISTINCT or GROUPparse§3.22
SELECT in metric modeparse§3.22
STREAM with COUNT BY, TOP N BY or GROUPparse§3.27
STREAM with UNTILparse§3.27
DISTINCT … STREAM with SORT, TAKE or SKIPparse§3.27
Window aggregation without SINCEparse§3.25
Scalar and window aggregation togetherparse§3.25
Two transformsparse§3.25
Cross-type filter without SINCEparse§3.26
= outside a label selectorparse§3.20
== NULL or != NULLparse§3.19
Ordering operator on a binary literalparse§3.20
Ordering operator on a fixed field that cannot be orderedparse or planning§3.20
Unknown log field nameparse§3.24
Effective range beyond the lookback limitplanning§3.26
Selected metric series spanning more than one typeexecution§3.25
RATE or DELTA on a gauge or histogramexecution§3.25
Percentile on a counter or gaugeexecution§3.25
Histogram series with no percentile functionexecution§3.25
Unbracketed metric query with SINCE resolving to several seriesexecution§3.25
Cross-type metric selector resolving to several seriesexecution§3.26
Aggregation producing a non-finite valueexecution§3.23, §3.25
A sort or aggregation needing more memory than the collector allows queriesexecution§3.16

"Parse" failures need no data. "Execution" failures depend on what the store holds, so the same query string may succeed on one system and fail on another.

3.B.4 Metric functions #

KeywordStageValid onProduces
RATEtransformcounterper-second change
DELTAtransformcounterabsolute change
P50 P95 P99transformhistogramone value per sample
AVG MIN MAX SUMscalar aggregationcounter, gaugeone value
AVG_OVER MIN_OVER MAX_OVER SUM_OVERwindow aggregationcounter, gaugeone value per window

Transforms feed aggregations; a query may have at most one of each (§3.25).

3.B.5 Operators #

== != > >= < <= STARTS_WITH ENDS_WITH CONTAINS HAS IN NOT_IN IS NULL IS NOT NULL, combined with AND and OR (§3.20).

CONTAINS is substring on a string; HAS is membership in an array.

There is no NOT and no =.

3.B.6 Literals #

KindFormSection
Identifier[A-Za-z_][A-Za-z0-9_.-]*§3.19
String"…" with \" \\ \n \r \t \uXXXX§3.19
Binaryx"0a1b…", even digit count§3.19
Integerdecimal or 0x…§3.19
Floatfinite, with a fraction or exponent§3.19
Booleantrue, false§3.19
NullNULL, in IS NULL only§3.19
Duration<n>s <n>m <n>h <n>d, non-zero§3.19
Time<duration> ago, <duration> hence, today, yesterday, YYYY-MM-DD, YYYY-MM-DDTHH:MM:SS§3.19
GUID8-4-4-4-12, braced or not§3.19

3.B.7 Fields #

ModeFixed fieldsEverything else
EVENTSevent.time event.sequence event.cpu event.type event.boot.guid emitter.class emitter.token.guid emitter.true-token.guid emitter.process.guida flattened payload path, or null
LOGStimestamp origin is_error message boot_id job_ida parse error
METRICtimestamp boot_id name type value overflowa label, or null

3.B.8 Aliases #

emitter.class accepts userspace (0), kmes (1), kacs (2), lcs (3). These are the only aliased values in the language (§3.23).

3.B.9 Default ordering #

ModeWithout SORT
EVENTSevent.time descending
LOGStimestamp descending
METRICtimestamp ascending
COUNT BY, TOP N BY, GROUP … COUNTcount descending
GROUP … SUM, AVG, MIN, MAXgroup keys ascending in the order named
DISTINCTby the distinct value

All ties are broken to a total order (§3.21).

Edit this page