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 SPL and knowledge objects

Going further with Splunk: CSV and KV store lookups, eventstats and streamstats, transaction vers...

Splunk: the machine data platform at a glance

Discover Splunk: the platform's role, components (forwarders, indexers, search heads), ports, eve...

Administering distributed Splunk

Designing and administering a production Splunk platform: reference architectures, indexer cluste...

Dashboards, reports and alerts in Splunk

Making the most of Splunk searches: reports and scheduling, Dashboard Studio dashboards (data sou...

Security and observability with Splunk

Splunk solutions beyond search: Enterprise Security (detections, findings, risk-based alerting, a...

Installing Splunk and ingesting data

Installing Splunk Enterprise (package or Docker), understanding $SPLUNK_HOME and configuration fi...

Splunk best practices

Best practices for running Splunk in production: data quality and sourcetypes, index design, lice...

Sources, destinations and routes in Cribl Stream

Receiving and sending data with Cribl Stream: push, pull, collector and internal sources, event b...

The observability trilemma: cost, completeness and performance, and how solutions resolve it

Understanding the observability trilemma (cost, data completeness, query performance), its three ...

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!