Azure/KqlKustoLogs
* Examples of Microsoft Azure KQL/Kusto log queries
let timeOffset = 7d; let discardEventId = 4688; SecurityEvent | where TimeGenerated > ago(timeOffset*2) and TimeGenerated < ago(timeOffset) | where EventID != discardEventId
let suspiciousAccounts = datatable(account: string) [ @"\administrator", @"NT AUTHORITY\SYSTEM" ]; SecurityEvent | where Account in (suspiciousAccounts)
let LowActivityAccounts = SecurityEvent | summarize cnt = count() by Account | where cnt < 10; LowActivityAccounts | where Account contains "Mal"
search "err"
search in (SecurityEvent,SecurityAlert,A*) "err"
SecurityEvent | where TimeGenerated > ago(1h) | where EventID == 4624 | where AccountType =~ "user"
SecurityAlert | where TimeGenerated > ago(7d) | extend severityOrder = case ( AlertSeverity == "High", 3, AlertSeverity == "Medium", 2, AlertSeverity == "Low", 1, AlertSeverity == "Informational", 0, -1)
let timeframe = 1d; let DomainList = dynamic(["tor2web.org", "tor2web.com"]); Syslog | where TimeGenerated >= ago(timeframe) | where ProcessName contains "squid" | extend HTTP_Status_Code = extract("(TCP_(([A-Z]+)…-9]{3}))",8,SyslogMessage), Domain = extract("(([A-Z]+ [a-z]{4…Z]+ )([^ :\\/]*))",3,SyslogMessage) | where HTTP_Status_Code == "200" | where Domain contains "." | where Domain has_any (DomainList)
SecurityAlert | where TimeGenerated > ago(7d) | extend severityOrder = case ( AlertSeverity == "High", 3, AlertSeverity == "Medium", 2, AlertSeverity == "Low", 1, AlertSeverity == "Informational", 0, -1) | order by severityOrder desc
SecurityEvent | where EventID == "4688" | summarize cnt=count() by Process, Computer
- count uniq ip's
SecurityEvent | summarize dcount(IpAddress)
- failed logins to disabled accounts, summarisze by User
let timeframe = 1d; let threshold = 3; SigninLogs | where TimeGenerated >= ago(timeframe) | where ResultType == "50057" | where ResultDescription =~ "User account is disabled. The account has been disabled by an administrator." | summarize applicationCount = dcount(AppDisplayName) by UserPrincipalName, IPAddress | where applicationCount >= threshold
SecurityEvent | where EventID == "4624" | summarize make_list(Account) by Computer
SecurityEvent | summarize count() by Account | render barchart