1. Search structure #
A pipeline of commands.
The principle #
A search starts with criteria (words, field=value, booleans AND, OR, NOT) that select events from indexes, then chains commands separated by |: each receives the previous result.
- Field names are case-sensitive, search criteria values are not; boolean operators are written in uppercase.
- Always start with
index=and, if possible,sourcetype=: it reduces indexer work the most.
Time #
| Syntax | Meaning |
|---|---|
| earliest=-24h latest=now | the last 24 hours |
| earliest=-1d@d latest=@d | yesterday, midnight to midnight |
| earliest=-7d@w1 | since Monday 7 days ago |
| earliest=-15m@m | last 15 minutes, snapped to the minute |
Fast, Smart (default) and Verbose modes set how many fields are extracted: Verbose shows everything but costs more.
2. Essential commands #
Filter, compute, aggregate.
Overview #
| Command | Role | Example |
|---|---|---|
| search / where | filter (where accepts expressions) | | where duration_ms > 2*avg_ms |
| eval | create or change a field | | eval kb = round(bytes/1024, 1) |
| stats | aggregate: count, dc, avg, sum, perc95, values | | stats count, avg(duration_ms) by uri |
| timechart | aggregate over time | | timechart span=15m count by status |
| chart | cross-tab | | chart count over uri by status |
| top / rare | most / least frequent values | | top limit=5 user |
| table, fields, rename | choose and name columns | | table _time user uri status |
| sort, dedup, head | sort, deduplicate, limit | | sort -count | head 10 |
Full searches #
index=web sourcetype=app:json earliest=-4h
| eval category = case(status>=500, "server error", status>=400, "client error", true(), "ok")
| stats count AS requests, perc95(duration_ms) AS p95 BY uri, category
| where requests > 20
| sort -p95index=web status>=500 | timechart span=5m count AS errors
index=security action=failure | stats dc(user) AS accounts, count BY src_ip | where accounts > 5Best practice : Aggregate as early as possible with stats: following commands work on a few rows instead of millions of events.3. Extracting fields #
rex, IFX and subsearches.
rex #
index=web sourcetype=nginx
| rex field=_raw "\"(?<method>GET|POST|PUT|DELETE) (?<path>[^ ?]+)"
| rex field=useragent "(?<browser>Firefox|Chrome|Safari|Edg)/(?<version>\d+)"
| stats count BY method, browserrexextracts fields with named groups(?<name>…);rex mode=sedreplaces text in results.- For a permanent extraction, use the field extractor (IFX) or an
EXTRACT-inprops.conf: everyone benefits. - JSON data:
KV_MODE = jsonor thespathcommand.
Subsearches #
index=web [ search index=security action=blocked earliest=-1h | dedup src_ip | rename src_ip AS client_ip | fields client_ip ]
| stats count BY client_ip, uriWatch out : A subsearch is limited (10,000 results and 60 seconds by default): beyond that, the result is truncated without a visible error. Prefer stats or a lookup.Commands to know #
Commands to know
index=web | stats count by status: count per value| timechart span=1h count by host: chart per host| eval duree_s = duration_ms/1000: compute a field| rex field=_raw "user=(?<user>\w+)": extract a field| top limit=10 uri: most frequent values| fieldsummary: summary of available fields
Sources #
Checked in November 2026 (Splunk Enterprise 10.6): check the release notes before relying on a detail, Splunk Cloud Platform evolves faster than the on-premises version.
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Advanced Grail and DQL: performance, parse, joins, time series, entities and correlation
Writing fast, low-cost DQL queries, parsing text with DPL and JSON, combining sources with lookup...
Pipelines and functions: parse, enrich, mask
Building Cribl Stream pipelines: pre-processing, processing and post-processing, the function cat...
Exploring data in Discover: KQL, Lucene and ES|QL
Search and analyze logs in Kibana Discover: filters, KQL, Lucene syntax, and the ES|QL language t...
Cribl: the data pipeline for observability and security
Discover Cribl: why a telemetry data pipeline, the Cribl suite (Stream, Edge, Lake, Search, Cribl...
Archiving, replaying and searching: S3, Replay, Cribl Lake and Cribl Search
Keeping all data cheaply and finding it on demand: partitioned S3 destination, JSON and Parquet f...
Thanos Ruler: rules and alerts on the global view
Evaluate recording and alerting rules across all clusters with Thanos Ruler: configuration, Alert...
Silences, inhibitions and time intervals in Alertmanager
Reduce alert noise: one-off silences with amtool, inhibition rules (a critical alert mutes second...
Elastic Security: SIEM, detection rules and investigation
Use Elastic Security as a SIEM: ECS data sources, detection rule types (query, EQL, ES|QL, thresh...
Kibana and Elastic Observability best practices
Checklist for running Kibana in production: versions, security, spaces and roles, versioned dashb...