35 Ueba Behaviors Ueba Layer Readiness
Query
// REVIEW ONLY - AWS Security Operations Workbook Visual Query
// Tab: UebaBehaviors | Panel: ueba-layer-readiness | Visualization: table | Mode: All
// Security Question: Are Classic UEBA (AWS CloudTrail & GuardDuty), Anomaly rules, and the New! UEBA Behaviors layer actively generating AWS insights?
// Drill-Through: Enable missing toggles under Microsoft Sentinel -> UEBA (Classic UEBA & New! Behaviors layer).
// Empty/No-Data Contract: Status catalog always renders 5 rows.
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 ExpectedLayers = datatable(Order:int, LayerName:string, BackingTables:string, PortalSetting:string)[
1, "Classic UEBA — AWS CloudTrail", "BehaviorAnalytics", "Sentinel -> UEBA -> Connect data sources -> AWS Cloud Trail",
2, "Classic UEBA — AWS GuardDuty", "BehaviorAnalytics", "Sentinel -> UEBA -> Connect data sources -> AWS Guard Duty",
3, "UEBA & ML Anomalies — AWS CloudTrail & GuardDuty", "Anomalies", "Sentinel -> Analytics -> Anomaly rules (Production / Flighting)",
4, "New! UEBA Behaviors Layer — AWS CloudTrail (184 Behaviors)", "SentinelBehaviorInfo / BehaviorInfo", "Sentinel -> UEBA -> New! Behaviors layer -> Enable + AWS Cloud Trail",
5, "New! UEBA Behaviors Entities — Amazon Web Services", "SentinelBehaviorEntities / BehaviorEntities", "Populated automatically when UEBA Behaviors layer processes AWSCloudTrail"
];
let Observed = union isfuzzy=true
(datatable(LayerName:string, TimeGenerated:datetime, Signal:string)[]),
(BehaviorAnalytics | where TimeGenerated between (Start .. End)
| where NativeTableName == "AWSCloudTrail" or EventSource has "CloudTrail" or (EventVendor has_any ("AWS", "Amazon") and ActivityType has_any ("LogOn", "SignIn", "ConsoleLogin"))
| project LayerName="Classic UEBA — AWS CloudTrail", TimeGenerated, Signal=coalesce(ActivityType, ActionType)),
(BehaviorAnalytics | where TimeGenerated between (Start .. End)
| where NativeTableName == "AWSGuardDuty" or EventSource has "GuardDuty"
| project LayerName="Classic UEBA — AWS GuardDuty", TimeGenerated, Signal=coalesce(ActivityType, ActionType)),
(Anomalies | where TimeGenerated between (Start .. End)
| where AnomalyTemplateName has_any ("AwsCloudTrail", "AWS", "GuardDuty") or RuleName has_any ("AwsCloudTrail", "AWS", "GuardDuty")
| project LayerName="UEBA & ML Anomalies — AWS CloudTrail & GuardDuty", TimeGenerated, Signal=coalesce(AnomalyTemplateName, RuleName)),
(SentinelBehaviorInfo | where TimeGenerated between (Start .. End)
| where DataSources has_any ("AWS", "CloudTrail", "Amazon") or AdditionalFields has "AWSCloudTrail"
| project LayerName="New! UEBA Behaviors Layer — AWS CloudTrail (184 Behaviors)", TimeGenerated, Signal=ActionType),
(BehaviorInfo | where TimeGenerated between (Start .. End)
| where ServiceSource == "Microsoft Sentinel" and (DataSources has_any ("AWS", "CloudTrail", "Amazon") or AdditionalFields has "AWSCloudTrail")
| project LayerName="New! UEBA Behaviors Layer — AWS CloudTrail (184 Behaviors)", TimeGenerated, Signal=ActionType),
(SentinelBehaviorEntities | where TimeGenerated between (Start .. End)
| where CloudPlatform =~ "Amazon Web Services" or DataSources has_any ("AWS", "CloudTrail")
| project LayerName="New! UEBA Behaviors Entities — Amazon Web Services", TimeGenerated, Signal=coalesce(CloudResourceType, EntityType))
| summarize AwsRows=count(), DistinctPatterns=dcount(Signal), LastEventUtc=max(TimeGenerated), SamplePatterns=make_set(Signal, 8)
by LayerName;
ExpectedLayers
| join kind=leftouter Observed on LayerName
| extend LayerStatus = iff(coalesce(AwsRows, 0) > 0, "🟢 ACTIVE: AWS behavioral records observed", "🟡 NO_ROWS_IN_WINDOW: Enable toggle in UEBA settings or widen TimeRange"),
FreshnessMin = iff(isnull(LastEventUtc), -1.0, round(datetime_diff('second', now(), LastEventUtc) / 60.0, 1))
| order by Order asc
| project LayerName, LayerStatus, AwsRows=coalesce(AwsRows, long(0)), DistinctPatterns=coalesce(DistinctPatterns, long(0)),
LastEventUtc, FreshnessMin, BackingTables, PortalSetting, SamplePatterns
| take 5000Explanation
This query is designed to check if various User and Entity Behavior Analytics (UEBA) layers in AWS, such as Classic UEBA (using AWS CloudTrail and GuardDuty), Anomaly rules, and the new UEBA Behaviors layer, are actively generating insights. It does this by:
- Setting up filters for time range, organization, AWS account, region, environment, workload, severity, source, summary mode, selected principal, and selected IP.
- Defining the expected UEBA layers and their corresponding data sources and settings.
- Collecting observed data from different sources like BehaviorAnalytics, Anomalies, SentinelBehaviorInfo, and BehaviorInfo, focusing on AWS CloudTrail and GuardDuty activities.
- Summarizing the observed data to count the number of AWS records, distinct patterns, the last event time, and sample patterns for each layer.
- Comparing the expected layers with the observed data to determine the status of each layer:
- "🟢 ACTIVE" if there are AWS behavioral records observed.
- "🟡 NO_ROWS_IN_WINDOW" if no records are observed, suggesting enabling the toggle in UEBA settings or widening the time range.
- Displaying the results in a table with details like layer name, status, number of AWS records, distinct patterns, last event time, freshness in minutes, backing tables, portal settings, and sample patterns, sorted by the order of layers.
The query ultimately helps in assessing whether the UEBA layers are functioning correctly and generating the expected insights from AWS data.