Query Language Syntax
CrowdStrike Query Language (CQL) is the syntax that lets you compose queries to retrieve, process, and analyze data in Falcon LogScale.
Built around a chain of data-processing commands linked together, CQL has each expression pass its result to the next expression in the sequence, creating complex queries. This architecture is similar to command pipes, a powerful and flexible mechanism for advanced data analysis in Unix and Linux shells.
This quick reference lists common syntax elements in CrowdStrike Query Language (CQL) with examples and links to detailed documentation.
Comments
Filters
- Free-text search
Search for text across all fields. See Query Filters.
error "connection refused"field=valueFilter events by exact field value. See Query Filters.
status=200 host=webserver01field=/regex/Filter using regular expression. See Query Filters and Regular Expression Syntax.
host=/web\d+/ message=/error|warning/i
Operators
=,!=Equality and inequality. See Operators.
status=200 status!=404<,>,<=,>=Comparison operators for numbers. See Operators.
status>=400 response_time<100and,or,notLogical operators. See Operators.
status=200 and method=GET status=404 or status=500 not errorinCheck if value is in a list. See Operators.
status in [200, 201, 204] host in [host1, host2]
For a complete operators reference, see Operators Reference.
Fields and Assignment
:=Assignment operator. Create or update a field. See Adding Fields to Events.
newfield := value status_category := "success"as=Assign result to field in function. See Adding Fields to Events.
groupBy(host, as=host_count) count(as=total_events)eval()Evaluate expression and assign to field. See Adding Fields to Events.
eval(total := price * quantity) eval(error_rate := errors / total * 100)- Regex extraction
Extract fields using named capture groups. See Adding Fields to Events.
/user=(?<username>\w+)/ /status=(?<code>\d+)/
User Parameters
?{parameter}Reference user parameter. See User Parameters/Variables.
host=?{hostname} status=?{status_code}?{parameter=default}Parameter with default value. See User Parameters/Variables.
host=?{hostname=localhost} limit=?{max_results=100}
Conditional Evaluation
caseConditional case statement. See Conditional Evaluation.
case { status<300 | level := "success" ; status<400 | level := "redirect" ; status<500 | level := "client_error" ; * | level := "server_error" }matchPattern matching statement. See Conditional Evaluation.
match { field="value1" | action := "first" ; field="value2" | action := "second" ; * | action := "default" }if()Conditional function. See Conditional Evaluation.
if(status>=400, "error", "ok") if(exists(field), field, "N/A")
Arrays and Objects
[index]Array element access by index. See Array Syntax.
tags[0] items[2].name[*]Array wildcard. See Array Syntax.
items[*].price users[*].email.fieldObject field access. See Array Syntax.
user.name response.data.id
Expressions
- Arithmetic:
+,-,*,/,% Mathematical operations. See Expressions.
total := price * quantity average := sum / count remainder := value % 10- Comparison in expressions
Compare values in expressions. See Expressions.
is_error := status >= 400 is_valid := count > 0
Functions and Pipes
|Pipe operator. Chain functions together. See Function Syntax.
groupBy(host) | count() | sort()function()Function call. See Function Syntax and Query Functions.
count() groupBy(field) top(limit=10)$saved_search()Reference saved search as function. See Saved Searches (User Functions) and Referencing Resources.
$web_logs() $error_analysis(severity="high")
Time Syntax
- Relative time modifiers
Specify relative time ranges. See Time Syntax.
-1h // 1 hour ago -24h // 24 hours ago -1d // 1 day ago -7d // 7 days ago -1w // 1 week ago- Time anchoring:
@ Snap to time unit boundary. See Time Syntax.
-1d@d // Start of yesterday -1w@w // Start of last week @h // Start of current hour- Rate units
Convert between rate units. See Time Syntax.
/s // per second /m // per minute /h // per hour /d // per day
Regular Expressions
/pattern/Regular expression literal. See Regular Expression Syntax.
/error|warning/ /\d{3}-\d{4}//pattern/flagsRegular expression with flags. See Regular Expression Syntax.
/error/i // case insensitive /pattern/m // multiline /pattern/s // dotall(?<name>pattern)Named capture group. See Regular Expression Syntax.
/user=(?<username>\w+)/ /status=(?<code>\d+)/
Additional Topics
Persisted Aggregations Syntax โ Query language requirements for persisted aggregations
Operators Reference โ Complete operators reference with precedence rules
Query Functions โ Complete function reference
Query Joins and Lookups โ Join methods between event sets