Query Details

AWS SecOps P0-08 - AWS Connector Failure, Ingestion Lag and Per-Source Blind Spot

P0 08 Aws Telemetry Blindspot And Health

Query

// REVIEW ONLY. Validate enabled AWS tables via discovery/D01 first and populate AWS_SourceSlaConfig
// ONLY for sources expected in this workspace.
let SlaConfig = _GetWatchlist('AWS_SourceSlaConfig')
| where tolower(tostring(column_ifexists("Enabled", ""))) == "true"
| project SourceTable=tostring(column_ifexists("SourceTable", "")), ConnectorPattern=tolower(tostring(column_ifexists("ConnectorNamePattern", ""))),
    ExpectedAccountId=tostring(column_ifexists("AWSAccountId", "")), ExpectedFreshnessMin=todouble(column_ifexists("ExpectedFreshnessMinutes", "")),
    ZeroVolumeMin=todouble(column_ifexists("ZeroVolumeAlertMinutes", "")), DropPctThreshold=todouble(column_ifexists("VolumeDropPctThreshold", ""));
let SourceStats = union
    (AWSCloudTrail | where TimeGenerated > ago(7d) | project SourceTable="AWSCloudTrail", TimeGenerated, Ingest=ingestion_time(), AWSAccountId=RecipientAccountId),
    (AWSGuardDuty | where TimeGenerated > ago(7d) | project SourceTable="AWSGuardDuty", TimeGenerated, Ingest=ingestion_time(), AWSAccountId=AccountId),
    (AWSVPCFlow | where TimeGenerated > ago(7d) | project SourceTable="AWSVPCFlow", TimeGenerated, Ingest=ingestion_time(), AWSAccountId=AccountId),
    (AWSRoute53Resolver | where TimeGenerated > ago(7d) | project SourceTable="AWSRoute53Resolver", TimeGenerated, Ingest=ingestion_time(), AWSAccountId=AccountId),
    (AWSWAF | where TimeGenerated > ago(7d) | project SourceTable="AWSWAF", TimeGenerated, Ingest=ingestion_time(), AWSAccountId="*"),
    (AWSNetworkFirewallAlert | where TimeGenerated > ago(7d) | project SourceTable="AWSNetworkFirewallAlert", TimeGenerated, Ingest=ingestion_time(), AWSAccountId="*")
| summarize
    LastEventUtc = max(TimeGenerated),
    LastIngestUtc = max(Ingest),
    Last24hEvents = countif(TimeGenerated > ago(24h)),
    BaselineDailyAvg = todouble(countif(TimeGenerated between (ago(7d) .. ago(1d)))) / 6.0,
    P95LagMin = round(percentile(datetime_diff('second', Ingest, TimeGenerated), 95) / 60.0, 1)
    by SourceTable, AWSAccountId;
let HealthIssues = SentinelHealth
| where TimeGenerated > ago(2h) and SentinelResourceType == "DataConnector"
| where Status in ("Failure", "Warning", "Partial Success")
| where SentinelResourceKind has_any ("AmazonWebServices", "AWS") or SentinelResourceName has_any ("AWS", "Amazon")
| summarize HealthErrorCount=count(), LatestHealthStatus=take_any(Status), HealthReasons=make_set(Reason, 10)
    by ConnectorLower=tolower(SentinelResourceName), SentinelResourceId;
SlaConfig
| join kind=leftouter SourceStats on SourceTable
| where ExpectedAccountId == "*" or isempty(AWSAccountId) or AWSAccountId == ExpectedAccountId
| extend FreshnessMin = iff(isnull(LastEventUtc), 999999.0, round(datetime_diff('second', now(), LastEventUtc) / 60.0, 1)),
    VolumeDropPct = iff(coalesce(BaselineDailyAvg, 0.0) >= 100.0, round(100.0 * (BaselineDailyAvg - todouble(coalesce(Last24hEvents, 0))) / BaselineDailyAvg, 1), 0.0)
| join kind=leftouter HealthIssues on $left.ConnectorPattern == $right.ConnectorLower
| extend BlindSpotClassification = case(
    coalesce(HealthErrorCount, 0) > 0 and FreshnessMin > ExpectedFreshnessMin, "SentinelConnectorFailureWithDataGap",
    coalesce(HealthErrorCount, 0) > 0, "SentinelConnectorDegradedWarning",
    FreshnessMin > ZeroVolumeMin, "ZeroVolumeOrDisconnectedBlindSpot",
    P95LagMin > ExpectedFreshnessMin and FreshnessMin > ExpectedFreshnessMin, "UpstreamAWSDeliveryDelay",
    VolumeDropPct >= coalesce(DropPctThreshold, 75.0), "SharpVolumeDropOrSchemaDrift",
    "")
| where isnotempty(BlindSpotClassification)
| extend TimeGenerated = now(),
    EffectiveAccount = coalesce(AWSAccountId, ExpectedAccountId),
    FreshnessMinStr = tostring(FreshnessMin),
    P95LagMinStr = tostring(coalesce(P95LagMin, 0.0)),
    VolumeDropPctStr = tostring(VolumeDropPct),
    HealthReasonsStr = tostring(coalesce(HealthReasons, dynamic([])))
| project TimeGenerated, SourceTable, AWSAccountId=EffectiveAccount, BlindSpotClassification,
    FreshnessMinStr, P95LagMinStr, VolumeDropPctStr, LastEventUtc, LastIngestUtc,
    ConnectorName=ConnectorPattern, SentinelResourceId=coalesce(SentinelResourceId, ""), HealthReasonsStr

Explanation

This query is a scheduled rule designed to monitor the health and performance of AWS data connectors in Microsoft Sentinel. Here's a simplified breakdown of what it does:

  1. Purpose: The rule checks for issues related to AWS data connectors, such as failures, ingestion delays, and unexpected drops in data volume. It helps identify whether problems are due to AWS delivery delays or issues with the Sentinel connectors themselves.

  2. Data Sources: It examines data from various AWS services like AWS CloudTrail, AWS GuardDuty, AWS VPC Flow, AWS Route53 Resolver, AWS WAF, and AWS Network Firewall Alert.

  3. Configuration:

    • It uses a watchlist (AWS_SourceSlaConfig) to define expected data freshness and volume thresholds for each data source.
    • It checks the last event time, ingestion time, and data volume over the past 24 hours and 7 days.
  4. Health Monitoring:

    • It looks for recent health issues with the data connectors in Sentinel, such as failures or warnings.
    • It distinguishes between issues caused by AWS upstream delays and those due to Sentinel connector failures.
  5. Classification:

    • The rule classifies issues into categories like "SentinelConnectorFailureWithDataGap," "ZeroVolumeOrDisconnectedBlindSpot," "UpstreamAWSDeliveryDelay," and "SharpVolumeDropOrSchemaDrift" based on the data freshness, volume drop, and health status.
  6. Incident Creation:

    • If any issues are detected, the rule creates an incident in Sentinel, grouping similar alerts together for easier management.
  7. Execution Frequency: The rule runs every hour and analyzes data from the past 7 days.

Overall, this query helps ensure that AWS data is being ingested into Sentinel as expected and alerts on any significant deviations or failures.