Iniciar sesión

Fields and values

10 min · 2 ejercicio(s)

field: value

KQL compares a field with a value. Spaces around the colon are optional:

user.name: m.keller
host.name:srv-web-01

Keyword fields are exact

Most security fields are mapped as keyword. A keyword is stored as one exact value, so the match is exact and case sensitive: process.name: WINWORD.EXE matches, process.name: winword.exe does not.

Fields of type text are analyzed (split into words, lower-cased). There, message: error also matches "An ERROR occurred".

Quoting values

If a value contains spaces or special characters, put it in double quotes. A quoted value is searched as a phrase:

event.reason: "bad password"

These characters have a special meaning and must be quoted or escaped with a backslash: \ ( ) : < > " * and whitespace.

Searching without a field

You can also type just a value. KQL then searches all fields. This is handy to explore unknown data, but it is slower and less precise, so in rules and dashboards always name the field.

🔎 Profundiza: funciones, errores habituales y práctica

How a value is matched depends on the mapping

Field type field: value behaves like Example
keyword exact, case sensitive term match user.name: m.keller
text analyzed full-text match (any word, case insensitive) message: timeout
ip exact IP or CIDR range source.ip: 10.10.0.0/16
long, double numeric equality destination.port: 443
date date equality or range @timestamp >= "2026-03-12"
boolean true / false tls.established: true

Many ECS fields are keywords with a .text sub-field for full text (for example process.command_line.text). Use the keyword for exact matches and wildcards, the text sub-field to find a word anywhere.

Quotes change the meaning

  • message: quick brown matches documents with quick or brown in a text field.
  • message: "quick brown" matches the phrase, both words next to each other in this order.
  • On a keyword field both forms must match the complete value.

Pitfalls

  • Case: process.name: powershell.exe won't find PowerShell.exe on a keyword field. In Elastic Security many fields also have a .caseless variant.
  • Typos in the field name don't raise an error, they just return 0 hits. In Kibana the autocompletion helps, in the lab use the field list on the right.
  • Multi-value fields: event.category: process also matches ["process", "network"]. A document matches if any value matches.

Ejercicios prácticos de esta lección

Resuelve estos ejercicios con una consulta en el laboratorio Elasticsearch real. Inicia sesión gratis para acceder al laboratorio, las pistas y la corrección automática.

  1. 1. Logons of one user

    The finance team reported that m.keller behaved strangely. How many authentication events exist for this user in lab-auth?

  2. 2. Find a phrase

    Write a query that returns all logon events whose event.reason is invalid user. Your query is graded by its result.