D05 Awsroute53resolver Schema Check
Query
// REVIEW ONLY - Mandatory Step 1: AWSRoute53Resolver Schema, SrcIds & Answer Bag Keys Discovery
// Validates Resolver Query Log coverage, DNS Firewall fields, and SrcIds dynamic structure (instance/eni).
AWSRoute53Resolver
| where TimeGenerated > ago(24h)
| extend SrcIdKeys = bag_keys(SrcIds),
SampleAnswerKeys = iff(array_length(Answers) > 0, bag_keys(Answers[0]), dynamic([]))
| summarize
QueryCount = count(),
LogTypes = make_set(LogType, 10),
Rcodes = make_set(Rcode, 20),
QueryTypes = make_set(QueryType, 20),
FirewallActions = make_set(FirewallRuleAction, 10),
ObservedSrcIdKeys = make_set(SrcIdKeys, 20),
ObservedAnswerKeys = make_set(SampleAnswerKeys, 20)
by AccountId, Region, VpcId
| order by QueryCount desc
| take 200Explanation
This query is designed to analyze and summarize DNS query logs from AWS Route 53 Resolver over the past 24 hours. Here's a breakdown of what it does:
-
Data Source: It uses the
AWSRoute53Resolvertable, which contains DNS query logs. -
Time Filter: It filters the logs to only include those generated in the last 24 hours.
-
Key Extraction:
- It extracts the keys from the
SrcIdsfield into a new column calledSrcIdKeys. - It also extracts keys from the first element of the
Answersarray (if it exists) into a column calledSampleAnswerKeys.
- It extracts the keys from the
-
Aggregation:
- It counts the total number of queries (
QueryCount). - It collects unique values for several fields:
LogType: Types of logs.Rcode: Response codes.QueryType: Types of DNS queries.FirewallRuleAction: Actions taken by DNS firewall rules.ObservedSrcIdKeys: Unique keys observed in theSrcIdsfield.ObservedAnswerKeys: Unique keys observed in theAnswersfield.
- It counts the total number of queries (
-
Grouping: The results are grouped by
AccountId,Region, andVpcId. -
Ordering and Limiting:
- The results are ordered by
QueryCountin descending order, showing the most queried accounts, regions, and VPCs first. - It limits the output to the top 200 results.
- The results are ordered by
In simple terms, this query helps you understand the distribution and characteristics of DNS queries in your AWS environment, focusing on the last 24 hours and highlighting the most active accounts, regions, and VPCs.