KQL (Kibana Query Language) is a powerful and user-friendly query syntax for searching and filtering logs and events in Kibana. This cheat sheet covers the most common syntax patterns you'll use.
KQL uses the field:value format.
status:200
user.name:"john"
geo.country_name:"Germany"Use quotes for values with spaces or special characters.
You can combine multiple conditions with the following logical operators:
AND— both conditions must be trueOR— at least one must be trueNOT— exclude a condition
status:404 AND extension:"jpg"
status:200 OR status:201
NOT geo.country_name:"Germany"You can also chain multiple:
status:404 OR status:500 OR status:503Use wildcards to do partial or fuzzy matches:
*— matches any number of characters?— matches a single character
user.name.keyword:jo*
extension:jp?
url.path.keyword:/products/*Note: Wildcards work only on fields that are keyword or not analyzed.
You can filter numeric and date fields using ranges.
bytes > 1000
status:[200 TO 299]
response_time >= 500@timestamp > "2024-01-01T00:00:00Z"
@timestamp:[now-7d TO now]Use the time picker in Kibana UI to complement timestamp queries.
Check whether a field exists (or not):
_exists_:field_name
NOT _exists_:field_name_exists_:response_time
NOT _exists_:parsed.URLUse parentheses to group expressions and control evaluation order.
(status:404 OR status:500) AND extension:"html"Without parentheses, the default precedence might lead to unexpected results.
Escape characters like :, ", /, etc. using a backslash (\).
url:"https:\/\/example.com\/home"You typically need escaping only in literal strings or exact matches.
For exact string matching, use .keyword fields. These are un-analyzed and return exact values.
user.name.keyword:"Alice Smith"
parsed.URL.keyword:*example.com*
logLevel.keyword:"ERROR"Without .keyword, Kibana might do full-text search instead of exact match.
Here are some useful examples you can try:
status >= 500parsed.URL.keyword:*nexxt.com*NOT _exists_:response_timeuser.role:"admin"@timestamp > now-24h AND logLevel.keyword:"ERROR"- KQL is case-insensitive for field names, but values may be case-sensitive.
- Use
.keywordfields when matching exact strings. - KQL does not support regex — if you need regex, switch to Lucene query syntax in the Kibana search bar.
- The time filter in the Kibana UI always affects your search results — set it to the appropriate range (
Last 15 minutes,Last 7 days,Last year, etc.). - If you don’t know the exact field name, use Kibana’s field list on the left sidebar or start typing — it often auto-suggests field names and values.
Happy querying! 🚀