Перейти к основному содержимому
Splunk (SPL) & Elastic Security (KQL/EQL) Operations
Урок 5 из 13

Splunk (SPL) & Elastic Security (KQL/EQL) Operations

Write effective Splunk SPL pipelines and Elastic Security KQL and EQL queries to filter authentication telemetry, aggregate brute-force spikes, and detect ordered attack sequences.

Средний 30 мин Blue Team / SOC
Этого урока пока нет на выбранном языке — показана версия на другом языке. Перевод готовится.

Цели обучения

  • Build fast Splunk SPL search pipelines using early filtering, bin, stats, and where
  • Filter normalized ECS telemetry in Elastic Discover with Kibana Query Language (KQL)
  • Write stateful Elastic Event Query Language (EQL) sequences to catch multi-step attacks
  • Distinguish targeted brute-force attacks from password spraying and credential stuffing using distinct counts

Рекомендуется заранее: SIEM Architecture, Normalization & Correlation Rules

#Why this matters

Once a SIEM normalizes and indexes incoming logs, SOC analysts spend most of their shift writing queries to validate alerts, hunt hidden threats, and build timelines. Splunk and Elastic Security dominate enterprise SOCs, and although their storage architectures differ, both rely on the same analytical workflow: narrow the dataset early, group events across time, and surface anomalous entities.

Learning how to translate one threat hypothesis across Splunk's Search Processing Language (SPL) and Elastic's Kibana Query Language (KQL) and Event Query Language (EQL) makes you effective in almost any blue-team environment.

#Splunk Search Processing Language (SPL)

SPL works like a Unix command pipeline. Everything to the left of the first pipe (|) selects raw or indexed events; each piped command transforms or aggregates the results passed to it.

  1. Selectindex=auth_logs sourcetype=... EventCode=4625
  2. Bucketbin _time span=5m
  3. Aggregatestats count dc(TargetUserName) by _time, IpAddress
  4. Filterwhere failed_attempts >= 15 OR distinct_users >= 5
  5. Ranksort - failed_attempts

Always filter as specifically as possible before the first pipe. Specifying index, sourcetype, and exact field-value pairs avoids reading unrelated gigabytes from disk.

SPL command Purpose Common example
bin Round timestamps into fixed buckets bin _time span=5m
stats Group and aggregate events stats count dc(user) by src_ip
timechart Build a time-series table for charts timechart span=1h count by action
eval Create or transform a calculated field eval mb=round(bytes/1048576, 2)
where Filter after aggregation or using expressions where failed_attempts >= 15
table / sort Select columns and order results sort - count

Consider hunting Windows logon failures (EventCode=4625) in SPL. Counting total failures catches noisy brute force against one account, while dc(TargetUserName) (distinct count) catches password spraying where an attacker tries one password against dozens of accounts:

spl
index=auth_logs sourcetype="WinEventLog:Security" EventCode=4625
| bin _time span=5m
| stats count AS failed_attempts dc(TargetUserName) AS distinct_users values(TargetUserName) AS users BY _time, IpAddress
| where failed_attempts >= 15 OR distinct_users >= 5
| sort - failed_attempts

If 198.51.100.42 fails 40 times against alice, failed_attempts triggers the alert. If 203.0.113.18 tries 12 usernames once each, distinct_users catches it even though per-account lockouts never fired.

#Elastic Security: KQL and EQL

Elastic Security splits querying into two complementary languages built on top of Elastic Common Schema (ECS) fields:

  • KQL (Kibana Query Language) filters documents in Discover, Dashboards, and threshold rules. It uses field: value pairs, boolean operators (and, or, not), parentheses, and wildcards (*).
  • EQL (Event Query Language) matches ordered sequences and relationships across events over time. Unlike KQL, EQL tracks state across multiple events sharing a common key.

In Discover, an analyst isolates external failed logins while excluding an authorized lab scanner (192.0.2.50) using KQL:

text
event.category: "authentication" and event.outcome: "failure" and not source.ip: 192.0.2.50

When you need to prove an attacker did not just knock on the door, but actually got in, switch to EQL. The sequence below matches two failed authentications followed by a success from the same source.ip and targeting the same user.name within 5 minutes:

eql
sequence by source.ip, user.name with maxspan=5m
  [authentication where event.outcome == "failure"]
  [authentication where event.outcome == "failure"]
  [authentication where event.outcome == "success"]

EQL uses the event category (authentication, process, network, file) directly inside square brackets and joins steps using the fields listed after sequence by.

Language Primary role Grouping or state Best suited for
Splunk SPL Search, transform, and aggregate stats ... by / bin Ad-hoc hunting, baselines, dashboards
Elastic KQL Fast document filtering None (filter only) Triage in Discover, simple alert filters
Elastic EQL Stateful event correlation sequence by ... with maxspan Brute force then success, suspicious process chains

#Common mistakes

  • Filtering late in SPL: running index=* | search EventCode=4625 forces Splunk to retrieve all indexes before discarding unwanted events. Put index, sourcetype, and static field filters before the first pipe.
  • Confusing count and dc: relying solely on count misses low-and-slow password spraying, where each username sees only one failed attempt per hour.
  • Forgetting by keys in EQL: omitting the join entity after sequence lets step 1 match host A and step 2 match host B, producing nonsensical false positives.
  • Leading wildcards in KQL: queries like process.command_line: *encoded* force expensive substring scans across unindexed fragments; prefer structured ECS fields or exact tokens whenever available.

#Summary

  • Splunk SPL pipes events left-to-right from index selection through time bucketing (bin), aggregation (stats), and post-aggregation filtering (where).
  • Distinct counts (dc in SPL) separate single-account brute force from multi-account password spraying and credential stuffing.
  • Elastic Security pairs KQL for fast document filtering with EQL for stateful, time-bounded sequence detection across shared entities.
  • Placing strict filters early in SPL and specifying accurate join keys in EQL keeps queries fast and alerts high-signal.

Проверка знаний

Войдите, чтобы проходить тест, завершать уроки и сохранять прогресс. Войти в систему