Skip to content
SOC Analyst Prep
  • Loading index…

↑↓ navigate · ↵ open · Esc close

en

Cheat sheet

Splunk SPL vs Sentinel KQL cheat sheet

The same SOC hunt, written in both languages, with the one translation gotcha that trips people up. Search by technique, table, operator or event ID.

Operator translation at a glance

Splunk SPLSentinel KQL
index=… sourcetype=…TableName (e.g. SecurityEvent)
search / wherewhere
stats count by xsummarize count() by x
stats dc(x)summarize dcount(x)
stats values(x)summarize make_set(x)
eval new=…extend new = …
table a b cproject a, b, c
rename a AS bproject-rename b = a
sort - countorder by count_ desc
head 10take 10 / top 10 by …
dedup xdistinct x (or summarize arg_max)
timechart span=1h countsummarize count() by bin(TimeGenerated, 1h) | render timechart
earliest=-24hwhere TimeGenerated > ago(24h)
rex field=x "(?<y>…)"extend y = extract("…", 1, x)

Hunts, side by side

25 of 25 hunts

Search and filter events for one user

Basics
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4625 user=jsmith
Sentinel KQL
SecurityEvent
| where EventID == 4625
| where TargetUserName =~ "jsmith"

SPL field values are case-insensitive by default, while KQL == is case-sensitive, so use =~ (or has) when you do not control the casing.

Limit a search to the last 24 hours

Basics
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4624 earliest=-24h@h latest=now
Sentinel KQL
SecurityEvent
| where TimeGenerated between (ago(24h) .. now())
| where EventID == 4624

Splunk can snap time with @h; ago(24h) does not snap, so use startofday() or bin() if you need aligned boundaries, and always filter TimeGenerated first for performance.

Count events by user and source IP

Basics
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4625
| stats count by user, src_ip
| sort - count
Sentinel KQL
SecurityEvent
| where EventID == 4625
| summarize Count = count() by TargetAccount, IpAddress
| sort by Count desc

stats ... by maps to summarize ... by; KQL needs an explicit column name for the aggregate if you want to sort on it cleanly.

Most and least common process names

Basics
Splunk SPL
index=sysmon EventCode=1
| top limit=10 Image

index=sysmon EventCode=1
| rare limit=10 Image
Sentinel KQL
DeviceProcessEvents
| summarize Count = count() by FileName
| top 10 by Count desc

DeviceProcessEvents
| summarize Count = count() by FileName
| top 10 by Count asc

SPL top/rare count and add a percent column for you; KQL top only sorts and takes N rows, so you must summarize first.

Unique user and source pairs for RDP logons

Basics
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4624 Logon_Type=10
| dedup user, src_ip
| table _time, user, src_ip, host
Sentinel KQL
SecurityEvent
| where EventID == 4624 and LogonType == 10
| distinct TargetAccount, IpAddress, Computer

dedup keeps the whole most recent event, whereas distinct returns only the listed columns; use summarize arg_max(TimeGenerated, *) by TargetAccount, IpAddress to keep full rows like dedup.

Rename and select output columns

Basics
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4624
| rename src_ip AS SourceIP, user AS Account
| table _time, Account, SourceIP, host
Sentinel KQL
SecurityEvent
| where EventID == 4624
| project TimeGenerated, Account = TargetAccount, SourceIP = IpAddress, Computer

KQL project both renames and selects in one step; use project-rename if you want to keep all other columns.

Calculate new fields (error flag, URI length)

Basics
Splunk SPL
index=web sourcetype=access_combined
| eval is_error=if(status>=500, 1, 0), uri_len=len(uri)
| stats sum(is_error) AS errors avg(uri_len) AS avg_uri_len by clientip
Sentinel KQL
W3CIISLog
| extend IsError = iff(toint(scStatus) >= 500, 1, 0), UriLen = strlen(csUriStem)
| summarize Errors = sum(IsError), AvgUriLen = avg(UriLen) by cIP

eval maps to extend and if() to iff(); in W3CIISLog the scStatus column is a string, so cast it with toint() before numeric comparison.

Failed logons per hour as a chart

Basics
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4625 earliest=-24h
| timechart span=1h count AS failed_logons
Sentinel KQL
SecurityEvent
| where TimeGenerated > ago(24h) and EventID == 4625
| summarize FailedLogons = count() by bin(TimeGenerated, 1h)
| render timechart

timechart fills empty buckets with zero but summarize by bin() simply omits them; use make-series in KQL when gaps matter for baselining.

Enrich logons with a privileged-accounts list

Basics
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4624
| lookup privileged_accounts.csv user OUTPUT role
| where isnotnull(role)
| table _time, user, role, src_ip, host
Sentinel KQL
let PrivAccounts = _GetWatchlist('PrivilegedAccounts')
| project TargetUserName = tostring(SearchKey), Role = tostring(Role);
SecurityEvent
| where EventID == 4624
| join kind=inner PrivAccounts on TargetUserName
| project TimeGenerated, TargetUserName, Role, IpAddress, Computer

Sentinel watchlists replace Splunk lookup files; remember KQL's default join is innerunique, which silently dedups the left side, so state kind=inner explicitly.

Failed logons by source IP (brute force or spraying)

AuthenticationT1110
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4625 earliest=-1h
| stats count AS failures dc(user) AS distinct_users values(user) AS targeted by src_ip
| where failures > 20
| sort - failures
Sentinel KQL
SecurityEvent
| where TimeGenerated > ago(1h) and EventID == 4625
| summarize Failures = count(), DistinctUsers = dcount(TargetAccount), Targeted = make_set(TargetAccount, 20) by IpAddress
| where Failures > 20
| sort by Failures desc

dc()/values() map to dcount()/make_set(); a high distinct-user count from one IP points to spraying, a low one to brute force.

Brute force followed by a successful logon

AuthenticationT1110.001
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security (EventCode=4625 OR EventCode=4624) earliest=-1h
| eval fail_time=if(EventCode=4625, _time, null()), success_time=if(EventCode=4624, _time, null())
| stats count(fail_time) AS failures min(fail_time) AS first_fail count(success_time) AS successes max(success_time) AS last_success by src_ip, user
| where failures >= 10 AND successes > 0 AND last_success > first_fail
| convert ctime(first_fail) ctime(last_success)
Sentinel KQL
let Failures = SecurityEvent
| where TimeGenerated > ago(1h) and EventID == 4625
| summarize FailCount = count(), FirstFail = min(TimeGenerated) by IpAddress, TargetAccount;
SecurityEvent
| where TimeGenerated > ago(1h) and EventID == 4624
| summarize LastSuccess = max(TimeGenerated) by IpAddress, TargetAccount
| join kind=inner Failures on IpAddress, TargetAccount
| where FailCount >= 10 and LastSuccess > FirstFail
| project IpAddress, TargetAccount, FailCount, FirstFail, LastSuccess

SPL usually solves this in one pass with conditional stats, while KQL reads more naturally as two let sets joined on IP and account.

Sign-ins from multiple countries (impossible travel)

AuthenticationT1078.004
Splunk SPL
index=o365 sourcetype=o365:management:activity Workload=AzureActiveDirectory Operation=UserLoggedIn earliest=-24h
| iplocation ClientIP
| stats dc(Country) AS countries values(Country) AS country_list values(ClientIP) AS ips by UserId
| where countries > 1
Sentinel KQL
SigninLogs
| where TimeGenerated > ago(24h) and ResultType == "0"
| extend Country = tostring(LocationDetails.countryOrRegion)
| summarize Countries = dcount(Country), CountryList = make_set(Country), IPs = make_set(IPAddress), Apps = make_set(AppDisplayName) by UserPrincipalName
| where Countries > 1

Splunk geolocates at search time with iplocation, while SigninLogs already carries LocationDetails; ResultType is a string, so compare to "0" not 0.

Account lockouts and where they came from (4740)

AuthenticationT1110
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4740
| stats count values(Caller_Computer_Name) AS caller_computers by user
| sort - count
Sentinel KQL
SecurityEvent
| where EventID == 4740
| summarize Lockouts = count(), CallerComputers = make_set(TargetDomainName) by TargetAccount
| sort by Lockouts desc

In SecurityEvent the 4740 Caller Computer Name lands in the TargetDomainName column, a well-known quirk that trips people up when translating.

New user accounts created (4720)

AuthenticationT1136.001
Splunk SPL
index=wineventlog sourcetype=WinEventLog:Security EventCode=4720
| table _time, host, src_user, user
| rename src_user AS created_by, user AS new_account
Sentinel KQL
SecurityEvent
| where EventID == 4720
| project TimeGenerated, Computer, CreatedBy = SubjectAccount, NewAccount = TargetAccount

The Splunk Windows add-on normalises creator and target to src_user and user, whereas SecurityEvent keeps the raw SubjectAccount/TargetAccount split.

Encoded PowerShell command lines

ProcessT1059.001
Splunk SPL
index=sysmon EventCode=1 (Image="*\\powershell.exe" OR Image="*\\pwsh.exe") (CommandLine="* -e *" OR CommandLine="* -ec *" OR CommandLine="*-enc*")
| table _time, host, User, ParentImage, CommandLine
Sentinel KQL
DeviceProcessEvents
| where TimeGenerated > ago(7d)
| where FileName in~ ("powershell.exe", "pwsh.exe")
| where ProcessCommandLine matches regex @"(?i)\s-(e|ec|en\w*)\s"
| project TimeGenerated, DeviceName, AccountName, InitiatingProcessFileName, ProcessCommandLine

PowerShell accepts any prefix of -EncodedCommand, so a regex beats fixed strings; the payload is UTF-16LE Base64, so decoded text shows null bytes unless you strip them.

Office applications spawning shells or script hosts

ProcessT1204.002
Splunk SPL
index=sysmon EventCode=1 (ParentImage="*\\winword.exe" OR ParentImage="*\\excel.exe" OR ParentImage="*\\powerpnt.exe" OR ParentImage="*\\outlook.exe") (Image="*\\cmd.exe" OR Image="*\\powershell.exe" OR Image="*\\wscript.exe" OR Image="*\\cscript.exe" OR Image="*\\mshta.exe" OR Image="*\\rundll32.exe")
| table _time, host, User, ParentImage, Image, CommandLine
Sentinel KQL
DeviceProcessEvents
| where InitiatingProcessFileName in~ ("winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe")
| where FileName in~ ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe", "mshta.exe", "rundll32.exe", "regsvr32.exe")
| project TimeGenerated, DeviceName, AccountName, InitiatingProcessFileName, FileName, ProcessCommandLine

Sysmon gives full paths so SPL needs wildcards with escaped backslashes, while MDE splits out bare FileName values that suit a case-insensitive in~ list.

Rare parent-child process pairs

ProcessT1059
Splunk SPL
index=sysmon EventCode=1 earliest=-7d
| eval parent=lower(mvindex(split(ParentImage, "\\"), -1)), child=lower(mvindex(split(Image, "\\"), -1))
| stats count dc(host) AS hosts values(host) AS host_list by parent, child
| where count < 5
| sort count
Sentinel KQL
DeviceProcessEvents
| where TimeGenerated > ago(7d)
| summarize Count = count(), Hosts = dcount(DeviceName), HostList = make_set(DeviceName, 10) by Parent = tolower(InitiatingProcessFileName), Child = tolower(FileName)
| where Count < 5
| sort by Count asc

In SPL you must carve the file name out of the path with split/mvindex; KQL can compute grouping keys inline inside summarize ... by.

certutil used to download or decode files (LOLBin)

ProcessT1105
Splunk SPL
index=sysmon EventCode=1 (Image="*\\certutil.exe" OR OriginalFileName="CertUtil.exe") (CommandLine="*urlcache*" OR CommandLine="*verifyctl*" OR CommandLine="*-decode*")
| table _time, host, User, ParentImage, CommandLine
Sentinel KQL
DeviceProcessEvents
| where FileName =~ "certutil.exe" or ProcessVersionInfoOriginalFileName =~ "CertUtil.exe"
| where ProcessCommandLine has_any ("urlcache", "verifyctl", "decode")
| project TimeGenerated, DeviceName, AccountName, InitiatingProcessFileName, ProcessCommandLine

Matching on the original file name catches renamed copies; KQL has_any matches whole terms and is much faster than contains on large tables.

Outbound connections to rare destination ports

NetworkT1571
Splunk SPL
index=sysmon EventCode=3 Initiated=true NOT DestinationPort IN (80, 443, 53, 22, 25, 88, 123, 389, 445, 3389)
| where NOT (cidrmatch("10.0.0.0/8", DestinationIp) OR cidrmatch("172.16.0.0/12", DestinationIp) OR cidrmatch("192.168.0.0/16", DestinationIp))
| stats count dc(host) AS hosts values(Image) AS processes by DestinationPort
| where hosts < 3
| sort count
Sentinel KQL
DeviceNetworkEvents
| where TimeGenerated > ago(7d)
| where ActionType == "ConnectionSuccess" and RemoteIPType == "Public"
| where RemotePort !in (80, 443, 53, 22, 25, 88, 123, 389, 445, 3389)
| summarize Count = count(), Hosts = dcount(DeviceName), Processes = make_set(InitiatingProcessFileName, 10) by RemotePort
| where Hosts < 3
| sort by Count asc

Splunk needs cidrmatch() to drop private ranges, while MDE pre-classifies addresses in RemoteIPType; NOT x IN (...) becomes !in.

Long DNS queries (possible DNS tunnelling)

NetworkT1071.004
Splunk SPL
index=sysmon EventCode=22
| eval qlen=len(QueryName)
| where qlen > 60
| rex field=QueryName "(?<domain>[^.]+\.[^.]+)$"
| stats dc(QueryName) AS unique_queries max(qlen) AS max_len values(Image) AS processes by domain, host
| where unique_queries > 50
| sort - unique_queries
Sentinel KQL
DnsEvents
| where TimeGenerated > ago(24h) and SubType == "LookupQuery"
| where strlen(Name) > 60
| extend Domain = extract(@"([^.]+\.[^.]+)$", 1, Name)
| summarize UniqueQueries = dcount(Name), MaxLen = max(strlen(Name)), Clients = make_set(ClientIP, 10) by Domain
| where UniqueQueries > 50
| sort by UniqueQueries desc

rex maps to extract(); the naive last-two-labels regex misgroups domains like co.uk, so treat results as leads and check unique subdomain counts per parent domain.

One external sender hitting many recipients

EmailT1566
Splunk SPL
index=mail sourcetype=ms:o365:reporting:messagetrace earliest=-24h NOT SenderAddress="*@corp.example.com"
| stats dc(RecipientAddress) AS recipients values(Subject) AS subjects values(Status) AS statuses by SenderAddress, FromIP
| where recipients > 20
| sort - recipients
Sentinel KQL
EmailEvents
| where TimeGenerated > ago(24h) and EmailDirection == "Inbound"
| summarize Recipients = dcount(RecipientEmailAddress), Subjects = make_set(Subject, 5), Actions = make_set(DeliveryAction) by SenderFromAddress, SenderIPv4
| where Recipients > 20
| sort by Recipients desc

EmailEvents gives you EmailDirection and DeliveryAction directly, whereas Splunk message-trace data needs you to exclude your own domain and read the delivery Status yourself.

Delivered invoice or payment themed emails that failed authentication

EmailT1566.001
Splunk SPL
index=mail sourcetype=ms:o365:reporting:messagetrace Status=Delivered (Subject="*invoice*" OR Subject="*payment*" OR Subject="*wire transfer*")
| table _time, SenderAddress, FromIP, RecipientAddress, Subject
Sentinel KQL
EmailEvents
| where TimeGenerated > ago(7d) and EmailDirection == "Inbound" and DeliveryAction == "Delivered"
| where Subject has_any ("invoice", "payment", "wire transfer")
| extend Auth = parse_json(AuthenticationDetails)
| where tostring(Auth.DMARC) =~ "fail" or tostring(Auth.SPF) =~ "fail"
| project TimeGenerated, SenderFromAddress, SenderIPv4, RecipientEmailAddress, Subject, AuthenticationDetails

Message trace has no SPF/DKIM/DMARC verdicts, so in Splunk you pivot to gateway or header logs, while EmailEvents exposes them as JSON in AuthenticationDetails.

SQL injection patterns in web server logs

WebT1190
Splunk SPL
index=web sourcetype=access_combined
| eval decoded=urldecode(uri)
| where match(decoded, "(?i)(union\s+(all\s+)?select|or\s+1=1|sleep\(|benchmark\(|information_schema|' or ')")
| stats count values(status) AS statuses values(uri_path) AS paths by clientip
| sort - count
Sentinel KQL
W3CIISLog
| where TimeGenerated > ago(24h)
| extend Q = url_decode(csUriQuery)
| where Q matches regex @"(?i)(union\s+(all\s+)?select|or\s+1=1|sleep\(|benchmark\(|information_schema|' or ')"
| summarize Requests = count(), Statuses = make_set(scStatus), Paths = make_set(csUriStem, 10) by cIP
| sort by Requests desc

Decode before matching (urldecode vs url_decode) or encoded payloads slip past; also check the status codes, since a 200 on an injection payload matters more than a 403.

Mass file download from SharePoint or OneDrive

CloudT1530
Splunk SPL
index=o365 sourcetype=o365:management:activity Workload IN (SharePoint, OneDrive) Operation=FileDownloaded earliest=-24h
| bin _time span=1h
| stats dc(ObjectId) AS files values(ClientIP) AS ips by _time, UserId
| where files > 100
| sort - files
Sentinel KQL
OfficeActivity
| where TimeGenerated > ago(24h)
| where OfficeWorkload in ("SharePoint", "OneDrive") and Operation == "FileDownloaded"
| summarize Files = dcount(OfficeObjectId), IPs = make_set(ClientIP, 10) by UserId, bin(TimeGenerated, 1h)
| where Files > 100
| sort by Files desc

SPL buckets time with a separate bin command before stats, while KQL puts bin() inside the summarize ... by clause.

Suspicious inbox rule creation (forward, delete, move)

CloudT1564.008
Splunk SPL
index=o365 sourcetype=o365:management:activity Workload=Exchange (Operation=New-InboxRule OR Operation=Set-InboxRule OR Operation=UpdateInboxRules)
| search Parameters{}.Name IN (DeleteMessage, MoveToFolder, ForwardTo, RedirectTo, ForwardAsAttachmentTo)
| table _time, UserId, ClientIP, Operation, Parameters{}.Name, Parameters{}.Value
Sentinel KQL
OfficeActivity
| where OfficeWorkload == "Exchange"
| where Operation in~ ("New-InboxRule", "Set-InboxRule", "UpdateInboxRules")
| where Parameters has_any ("DeleteMessage", "MoveToFolder", "ForwardTo", "RedirectTo", "ForwardAsAttachmentTo")
| project TimeGenerated, UserId, ClientIP, Operation, Parameters

Splunk exposes the rule parameters as multivalue Parameters{}.Name/Value fields, whereas OfficeActivity stores them as a JSON string you can search with has_any or expand with parse_json.

How interviewers test SIEM query logic

Few SOC interviews ask you to type a perfect query from memory. What they test is whether you can think in queries: filter to the right events, aggregate to find the outlier, and explain why a result is or is not suspicious. Whether the team runs Splunk or Microsoft Sentinel, the same three patterns come up again and again in Splunk queries for SOC analyst interviews and their KQL equivalents.

1. Filtering failed logins

"How would you find brute force in the last hour?" The panel wants to hear: filter on Event ID 4625, group by source IP, count attempts and distinct usernames, and set a threshold. Many attempts against one user is password guessing; one attempt each against many users is spraying. Then say what you would join next: a 4624 from the same IP.

Failed logins by source (SPL)
index=wineventlog EventCode=4625 earliest=-1h
| stats count dc(user) AS users BY src_ip
| where count > 20
| sort - count
Failed logins by source (KQL)
SecurityEvent
| where TimeGenerated > ago(1h) and EventID == 4625
| summarize count(), users = dcount(TargetUserName) by IpAddress
| where count_ > 20
| order by count_ desc

Note the small Splunk vs KQL syntax differences interviewers like to probe: stats … BY becomes summarize … by, dc() becomes dcount(), and KQL names the count column count_.

2. Spotting suspicious parent-child processes

The second favourite: "How would you detect Office spawning PowerShell?" Filter process-creation events (4688 or Sysmon 1, or DeviceProcessEvents in Microsoft Defender) where the parent is winword.exe, excel.exe or outlook.exe and the child is powershell.exe, cmd.exe, wscript.exe or mshta.exe. Explain that the relationship is the signal: PowerShell alone is normal, PowerShell started by Word with -enc on the command line is not. The "Office applications spawning shells" and "Rare parent-child process pairs" hunts above show both versions.

3. Tuning false positives

L2-leaning interviews ask, "This rule fires 300 times a day. What do you do?" A strong answer avoids simply disabling it. Group the hits by host, user and process to find the noisy source, confirm it is benign (a backup agent, a vulnerability scanner, a service account with a stale password), then add a narrow exclusion such as NOT src_ip IN (…) or where Account !in (…), document why, and set a review date. Being able to describe that process is what separates Microsoft Sentinel KQL queries for SOC work from copy-pasted syntax.

To practise the reasoning on real-looking data, run the duplicate-ingestion false positive mission in the SOC simulator, and keep the Windows Event IDs cheat sheet open for the field names.

Go deeper

The SIEM: Splunk & KQL module walks through the brute-force and impossible-travel hunts step by step, then the impossible travel mission tests whether you can tell a VPN from an attacker.

Frequently asked questions

Should I learn Splunk SPL or KQL for a SOC interview?

Learn the one your target company uses, and the concepts in both. Many Indian service companies run Splunk or QRadar for clients, while Microsoft-heavy enterprises use Sentinel and Defender (KQL). The mental model — filter, aggregate, compare against a baseline — is the same.

What is the KQL equivalent of Splunk stats count by?

summarize count() by field. Note the count column is named count_ in KQL, so you sort with order by count_ desc.

Is KQL case-sensitive?

Table and column names and the == operator are case-sensitive; =~, has and contains are case-insensitive. SPL field values are generally case-insensitive in search but case-sensitive in where.

Why do my Splunk field names differ from the examples?

Field names depend on the add-on and sourcetype. The examples assume the Splunk Add-on for Microsoft Windows normalised fields (such as user and src_ip); raw XML Windows events use names like TargetUserName and IpAddress.