Query Details

18 Network Vpc Accept Reject Summary Trend

Query

// REVIEW ONLY - AWS Security Operations Workbook Visual Query
// Tab: Network | Panel: vpc-accept-reject-summary-trend | Visualization: timechart | Mode: All
// Security Question: Are rejected scan bursts or anomalous egress spikes occurring across monitored VPCs?
// Drill-Through: Inspect Panel 5.2 below and click a SourceIp row to drill into raw flows.
// Empty/No-Data Contract: No AWS_VPCFlow_5m_CL or AWSVPCFlow events in window (check Tab 2 Data Health: AWSVPCFlow).
let Start = {TimeRange:start};
let End = {TimeRange:end};
let OrgFilter = base64_decode_tostring("{Organization:base64}");
let AccountFilter = base64_decode_tostring("{AwsAccount:base64}");
let RegionFilter = base64_decode_tostring("{AwsRegion:base64}");
let EnvFilter = base64_decode_tostring("{Environment:base64}");
let WorkloadFilter = base64_decode_tostring("{Workload:base64}");
let SeverityFilter = base64_decode_tostring("{Severity:base64}");
let SourceFilter = base64_decode_tostring("{SourceTable:base64}");
let SummaryPref = base64_decode_tostring("{SummaryMode:base64}");
let SelectedPrincipalFilter = base64_decode_tostring("{SelectedPrincipal:base64}");
let SelectedIpFilter = base64_decode_tostring("{SelectedIp:base64}");
let SummaryRows = union isfuzzy=true
    (datatable(WindowStart:datetime, AccountId:string, Region:string, Action:string, FlowRecords:long)[]),
    (AWS_VPCFlow_5m_CL | where WindowStart between (Start .. End) | project WindowStart, AccountId, Region, Action, FlowRecords)
| where SummaryPref == "PreferSummary"
| where (AccountFilter == "*" or AccountId == AccountFilter) and (RegionFilter == "*" or Region == RegionFilter)
| summarize Flows=sum(FlowRecords) by TimeBucket=bin(WindowStart, 15m), Action;
let HasSummary = toscalar(SummaryRows | summarize count() > 0);
let RawFallbackRows = union isfuzzy=true
    (datatable(TimeGenerated:datetime, AccountId:string, Region:string, Action:string)[]),
    (AWSVPCFlow | where TimeGenerated between (Start .. End) | project TimeGenerated, AccountId, Region, Action)
| where SummaryPref == "RawOnly" or not(HasSummary)
| where (AccountFilter == "*" or AccountId == AccountFilter) and (RegionFilter == "*" or Region == RegionFilter)
| summarize Flows=count() by TimeBucket=bin(TimeGenerated, 15m), Action;
union SummaryRows, RawFallbackRows
| order by TimeBucket asc
| take 5000

Explanation

This KQL (Kusto Query Language) query is designed to analyze network activity within AWS Virtual Private Clouds (VPCs) to identify any unusual patterns, such as rejected scan bursts or unexpected outbound traffic spikes. Here's a simplified breakdown of what the query does:

  1. Time Range and Filters: The query starts by setting a time range (Start and End) and various filters (like organization, account, region, environment, workload, severity, source, summary mode, principal, and IP) using base64-decoded strings. These filters help narrow down the data to specific criteria.

  2. Data Retrieval:

    • Summary Data: It first attempts to retrieve summarized data from a table called AWS_VPCFlow_5m_CL. This data is grouped into 15-minute intervals and categorized by action (e.g., accept or reject) and the number of flow records.
    • Raw Data Fallback: If no summary data is available or if the preference is set to "RawOnly," it retrieves raw flow data from the AWSVPCFlow table, also grouped into 15-minute intervals by action.
  3. Data Filtering: Both summary and raw data are filtered based on the specified account and region filters.

  4. Data Combination and Ordering: The query combines the summary and raw data results, orders them by time, and limits the output to 5000 records.

  5. Purpose: The goal is to visualize trends in network activity, specifically looking for anomalies in traffic patterns across monitored VPCs. If any unusual activity is detected, users can drill down into specific IP addresses for further investigation.

  6. No Data Handling: If there are no relevant events within the specified time window, the query suggests checking another tab for data health.

Overall, this query helps AWS security operations teams monitor and investigate network traffic anomalies within their VPCs.