index=wineventlog sourcetype=WinEventLog:Security EventCode=4625 user=jsmith
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.
index=wineventlog sourcetype=WinEventLog:Security EventCode=4624 earliest=-24h@h latest=now
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.
index=wineventlog sourcetype=WinEventLog:Security EventCode=4625
| stats count by user, src_ip
| sort - count
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.
index=sysmon EventCode=1
| top limit=10 Image
index=sysmon EventCode=1
| rare limit=10 Image
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.
index=wineventlog sourcetype=WinEventLog:Security EventCode=4624 Logon_Type=10
| dedup user, src_ip
| table _time, user, src_ip, host
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.
index=wineventlog sourcetype=WinEventLog:Security EventCode=4624
| rename src_ip AS SourceIP, user AS Account
| table _time, Account, SourceIP, host
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.
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
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.
index=wineventlog sourcetype=WinEventLog:Security EventCode=4625 earliest=-24h
| timechart span=1h count AS failed_logons
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.
index=wineventlog sourcetype=WinEventLog:Security EventCode=4624
| lookup privileged_accounts.csv user OUTPUT role
| where isnotnull(role)
| table _time, user, role, src_ip, host
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.
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
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.
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)
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.
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
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.
index=wineventlog sourcetype=WinEventLog:Security EventCode=4740
| stats count values(Caller_Computer_Name) AS caller_computers by user
| sort - count
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.
index=wineventlog sourcetype=WinEventLog:Security EventCode=4720
| table _time, host, src_user, user
| rename src_user AS created_by, user AS new_account
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
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
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.
index=mail sourcetype=ms:o365:reporting:messagetrace Status=Delivered (Subject="*invoice*" OR Subject="*payment*" OR Subject="*wire transfer*")
| table _time, SenderAddress, FromIP, RecipientAddress, Subject
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.
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
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.
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
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.
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
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.