Splunk — Fundamentals
Why this exists (the hook)
The first time most people see a real SPL search, it looks like a wall of pipe characters and unfamiliar commands — index=web sourcetype=access status>=500 | stats count by host | sort -count. It looks intimidating exactly because it's dense, but the underlying idea is one most people already know from a completely different context: a Unix shell pipeline, where the output of one command becomes the input to the next. Once that click happens — "this is just grep | sort | uniq -c, for log data instead of files" — SPL stops looking like a new language to memorize and starts looking like a familiar pattern applied to a new kind of data.
Analogy
Think of an SPL search as an assembly line, not a single instruction. The search at the start is the intake station — it pulls in only the raw materials (events) that match a basic filter, the way a factory intake only accepts parts matching a spec. Each | (pipe) afterward is another station on the line, and each one does exactly one job to whatever comes down the belt from the station before it: stats is the counting station (tally up what came through, grouped however you specify), eval is the labeling station (stick a new label — a computed field — onto each item based on what's already on it), sort is the ordering station (arrange the output belt by whatever field you choose). Nothing upstream of a station knows or cares what happens downstream — which is exactly why SPL pipelines are readable left to right, one transformation at a time, instead of one dense, all-at-once instruction.
How it fits together (diagram)
Try it yourself (2 minutes)
Take this plain-English request: "Show me the 5 hosts that produced the most error-level events in the last hour, worst first." Without writing any real SPL yet, try breaking that sentence into pipeline stations the way the diagram above does: what's the intake filter (which events even qualify — "error-level," "last hour")? What's the counting station (group by what, count what)? What's the ordering station (worst first means sorted by what, in which direction)? What's the limiting station (top 5 only)? If you can name those four stations in order, you've already designed the shape of the real query below — search errorlevel=error earliest=-1h | stats count by host | sort -count | head 5 — before ever seeing the syntax.
What is Splunk, concretely?
| Splunk | ELK / Elasticsearch | Datadog Logs |
|---|
|---|---|---|---|
| Query language | SPL (Search Processing Language) | KQL / Lucene / DSL | Datadog log search syntax |
|---|---|---|---|
| Deployment | Self-hosted (Enterprise) or SaaS (Cloud) | Self-hosted or Elastic Cloud | SaaS only |
| Best known for | Security/SIEM depth, heterogeneous data | Full-text search, open-source flexibility | Unified metrics+logs+traces |
| Licensing | Ingest-based (GB/day) or workload-based (needs verification — recheck against current source) | Free core, paid tiers for advanced features | Per-GB, usage-based |
SPL Building Blocks
Every real SPL query starts with a search (often implicit — typing directly into the search bar begins one) and narrows through piped commands:
`stats` — Aggregation
`eval` — Computed Fields
`rex` — Regex Field Extraction
`timechart` — Time-Series Output
Interview Questions
What is the difference between stats and eval in SPL, and why does the order they're used in a pipeline matter?
eval operates per-event — it computes or transforms one field on each individual event as it passes through that stage of the pipeline, without reducing the number of events. stats operates across events — it collapses many events into summary rows grouped by whatever fields are specified, and after a stats command, the individual raw events are gone; only the aggregated result remains. Order matters because eval needs to run before stats if the aggregation should be grouped by a field eval just computed — stats can only group by fields that already exist on the events reaching it, so a pipeline that tries to eval a field after stats has already collapsed the data either fails to find the source fields it needs or computes something meaningless from the aggregated rows instead of the original events.
Why does Splunk remain widely used in security operations specifically, when open-source alternatives like the ELK stack are meaningfully cheaper?
Security teams typically can't dictate log format to the vendor appliances, network devices, and legacy systems already deployed across their environment — a firewall, a Windows domain controller, and a custom internal application will never agree on a common log schema, and requiring one before the data is searchable isn't realistic in most real enterprise environments. Splunk's core design — index heterogeneous data as-is, do field extraction and correlation at search time via SPL rather than requiring structure at write time — is specifically suited to that constraint, and its Enterprise Security product adds purpose-built SIEM capabilities (Notable Events, risk-based alerting, correlation searches) on top. ELK is a strong, often cheaper choice when an organization has more control over its log formats or is optimizing for full-text search at lower cost — the tradeoff is real, not one tool being unconditionally better than the other.

