D01 Workspace Aws Table Inventory
Query
// REVIEW ONLY - Mandatory Step 1: Workspace AWS & Cross-Cloud Table Inventory & Freshness Discovery
// Purpose: Validate which AWS S3/CCF, Entra ID, Defender XDR, and custom (_CL) tables are connected,
// populated, and within expected ingestion latency before enabling scheduled/NRT detections.
// Note: Uses union isfuzzy=true ONLY for discovery so missing optional tables do not abort inventory.
union isfuzzy=true withsource=DiscoveredTable
(AWSCloudTrail | where TimeGenerated > ago(7d) | project TimeGenerated, IngestTime=ingestion_time(), AccountHint=coalesce(RecipientAccountId, UserIdentityAccountId, ""), RegionHint=AWSRegion, BilledBytes=_BilledSize),
(AWSGuardDuty | where TimeGenerated > ago(7d) | project TimeGenerated, IngestTime=ingestion_time(), AccountHint=AccountId, RegionHint=Region, BilledBytes=_BilledSize),
(AWSVPCFlow | where TimeGenerated > ago(7d) | project TimeGenerated, IngestTime=ingestion_time(), AccountHint=AccountId, RegionHint=Region, BilledBytes=_BilledSize),
(AWSRoute53Resolver | where TimeGenerated > ago(7d) | project TimeGenerated, IngestTime=ingestion_time(), AccountHint=AccountId, RegionHint=Region, BilledBytes=_BilledSize),
(AWSWAF | where TimeGenerated > ago(7d) | project TimeGenerated, IngestTime=ingestion_time(), AccountHint=WebAclId, RegionHint=HttpSourceName, BilledBytes=_BilledSize),
(AWSNetworkFirewallAlert | where TimeGenerated > ago(7d) | project TimeGenerated, IngestTime=ingestion_time(), AccountHint=FirewallName, RegionHint=AvailabilityZone, BilledBytes=_BilledSize),
(AWSNetworkFirewallFlow | where TimeGenerated > ago(7d) | project TimeGenerated, IngestTime=ingestion_time(), AccountHint=FirewallName, RegionHint=AvailabilityZone, BilledBytes=_BilledSize),
(AWSCloudWatch | where TimeGenerated > ago(7d) | project TimeGenerated, IngestTime=ingestion_time(), AccountHint="InspectMessageJson", RegionHint="InspectMessageJson", BilledBytes=_BilledSize),
(SentinelHealth | where TimeGenerated > ago(7d) and SentinelResourceType == "DataConnector" | project TimeGenerated, IngestTime=ingestion_time(), AccountHint=SentinelResourceName, RegionHint=Status, BilledBytes=_BilledSize)
| summarize
Events7d = count(),
LastEventUtc = max(TimeGenerated),
LastIngestUtc = max(IngestTime),
FreshnessMinutes = round(datetime_diff('second', now(), max(TimeGenerated)) / 60.0, 1),
MedianIngestLagMinutes = round(percentile(datetime_diff('second', IngestTime, TimeGenerated), 50) / 60.0, 1),
P95IngestLagMinutes = round(percentile(datetime_diff('second', IngestTime, TimeGenerated), 95) / 60.0, 1),
DistinctAccountsOrScopes = count_distinct(AccountHint),
DistinctRegionsOrZones = count_distinct(RegionHint),
EstimatedBillableGB7d = round(sum(BilledBytes) / 1073741824.0, 3)
by DiscoveredTable
| order by DiscoveredTable asc
| take 100Explanation
This query is designed to review and validate the status of various AWS and cross-cloud tables, ensuring they are connected, populated, and have acceptable data ingestion latency before enabling scheduled or near-real-time detections. Here's a simplified breakdown of what the query does:
-
Data Sources: It checks several AWS services (like AWS CloudTrail, AWS GuardDuty, etc.) and SentinelHealth for data generated in the last 7 days.
-
Data Collection: For each service, it collects information such as the time the data was generated, the time it was ingested, account and region identifiers, and the size of the data billed.
-
Data Aggregation: It summarizes the collected data by:
- Counting the number of events in the last 7 days.
- Finding the most recent event and ingestion times.
- Calculating the freshness of the data in minutes.
- Measuring the median and 95th percentile of the ingestion lag time in minutes.
- Counting distinct accounts or scopes and regions or zones.
- Estimating the total billable data size in gigabytes over the last 7 days.
-
Output: The results are organized by the source table, sorted alphabetically, and limited to the first 100 entries.
This process helps ensure that the data from these tables is current and reliable before using it for further detection and analysis tasks.