RousselTMLEARNING

Article · Splunk: from discovery to expertise

SPL: the fundamentals

1. Search structure #

A pipeline of commands.

The principle #

SPL pipeline

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.

Search example
  • 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 #

SyntaxMeaning
earliest=-24h latest=nowthe last 24 hours
earliest=-1d@d latest=@dyesterday, midnight to midnight
earliest=-7d@w1since Monday 7 days ago
earliest=-15m@mlast 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 #

CommandRoleExample
search / wherefilter (where accepts expressions)| where duration_ms > 2*avg_ms
evalcreate or change a field| eval kb = round(bytes/1024, 1)
statsaggregate: count, dc, avg, sum, perc95, values| stats count, avg(duration_ms) by uri
timechartaggregate over time| timechart span=15m count by status
chartcross-tab| chart count over uri by status
top / raremost / least frequent values| top limit=5 user
table, fields, renamechoose and name columns| table _time user uri status
sort, dedup, headsort, 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 -p95
index=web status>=500 | timechart span=5m count AS errors
index=security action=failure | stats dc(user) AS accounts, count BY src_ip | where accounts > 5
Best 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, browser
  • rex extracts fields with named groups (?<name>…); rex mode=sed replaces text in results.
  • For a permanent extraction, use the field extractor (IFX) or an EXTRACT- in props.conf: everyone benefits.
  • JSON data: KV_MODE = json or the spath command.

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, uri
Watch 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.

📄 SPL: Splunk search fundamentals →

My progress

  • ⏱ Estimated time : ≈ 5 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

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...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!