What is KQL?
8 min · 1 ejercicio(s)
KQL (Kibana Query Language) is the filter language behind the search bar in Kibana. Whenever you open Discover, build a dashboard filter or write a custom query rule in Elastic Security, you are most likely typing KQL.
KQL does one thing very well: it filters documents. It does not aggregate, sort or transform data. Kibana turns your KQL into Elasticsearch Query DSL behind the scenes. Querynaut does exactly the same thing in the lab.
Your lab: Kestrel Logistics
All exercises run against real Elasticsearch indices with one week of telemetry (9 to 15 March 2026) from the fictional company Kestrel Logistics:
| Index | Content |
|---|---|
lab-auth |
Authentication events: Windows, VPN, SSH and SMB logons |
lab-endpoint |
Process starts, network connections and file events from workstations and servers |
lab-web |
Access logs of the public web shop running on srv-web-01 |
The fields follow the Elastic Common Schema (ECS), so what you learn here works with your own data as well: user.name, source.ip, event.outcome, process.name and so on. The field list is always shown next to the query editor.
Your first query
The simplest KQL query is a field, a colon and a value:
event.outcome: failureThis returns every event where the field event.outcome contains the value failure. An empty query matches everything.
Tip: In the lab you run a query with Ctrl + Enter (or ⌘ + Enter on a Mac).
🔎 Profundiza: funciones, errores habituales y práctica
Where you meet KQL
| Place | What KQL does there |
|---|---|
| Discover search bar | Filters the documents of the selected data view and time range |
| Dashboard query bar | Filters every panel on the dashboard at once |
| Elastic Security: timeline, custom query rules | Selects the events a detection rule alerts on |
| Alerts and cases filters | Narrows down alert lists |
kql query in Query DSL |
Recent Elasticsearch versions accept KQL directly inside a search request |
KQL vs. Lucene
Kibana also offers the older Lucene query syntax (toggle in the query bar). Lucene supports regular expressions and fuzzy search, KQL supports nested field queries and autocompletes field names. For day-to-day filtering KQL is the default and the one you should master first.
What KQL can't do
KQL can't count, group, sort or join. As soon as your question contains "how many per…", "the top 10…" or "first seen", reach for ES|QL. If your question is "A happened, and then B on the same host", reach for EQL.
Time is a filter too
In Kibana the time picker adds a range filter on @timestamp to every KQL query. Forgetting a wide enough time range is the most common reason for "0 hits". The Querynaut lab does not apply a time filter, so you always see the whole week.