Query Details
let query_frequency = 1h;
let query_period = 14d;
let _InternalDomains = toscalar(
_GetWatchlist("Domain-PrivDomains")
| where Notes has "[HomeTenant]"
| summarize make_list(Domain)
);
DnsEvents
| where TimeGenerated > ago(query_period)
| where Name has_any (_InternalDomains)
| summarize arg_min(TimeGenerated, *) by SubType, EventId, QueryType, ResultCode
| where TimeGenerated > ago(query_frequency)
| join kind=rightsemi (
DnsEvents
| where TimeGenerated > ago(query_frequency)
| where Name has_any (_InternalDomains)
) on SubType, EventId, QueryType, Result, ResultCode
| summarize arg_min(TimeGenerated, *) by SubType, EventId, QueryType, ResultCode, Name
| sort by TimeGenerated asc
| project
TimeGenerated,
SubType,
EventId,
Computer,
ClientIP,
QueryType,
Name,
Result,
ResultCode,
IPAddresses,
MaliciousIP
This KQL query is designed to analyze DNS events related to specific internal domains over a recent period. Here's a simple breakdown:
Setup Variables:
query_frequency is set to 1 hour, meaning the query focuses on events from the last hour.query_period is set to 14 days, indicating the overall time frame for the data analysis.Internal Domains:
Filter DNS Events:
Summarize Initial Events:
arg_min) of each unique combination of SubType, EventId, QueryType, and ResultCode within the filtered events.Recent Events:
Join with Recent DNS Events:
Final Summarization:
SubType, EventId, QueryType, ResultCode, and Name.Sorting and Projection:
TimeGenerated, SubType, EventId, Computer, ClientIP, QueryType, Name, Result, ResultCode, IPAddresses, and MaliciousIP.In essence, this query identifies and lists recent DNS events related to specific internal domains, focusing on the most recent occurrences and relevant details.

Jose Sebastián Canós
Released: November 11, 2024
Tables
Keywords
Operators