List all AuditLog activities of a user
Audit Logs User Activities
Query
let AccountUPN = "[email protected]";
let SearchWindow = 48h; //Customizable h = hours, d = days
AuditLogs
| where TimeGenerated > ago(SearchWindow)
| extend InitiatingUser = parse_json(InitiatedBy.user)
| extend InitatingUPN = parse_json(InitiatingUser).userPrincipalName
| where InitatingUPN == AccountUPN
| project-reorder TimeGenerated, InitatingUPN, OperationName, ResultDescription, ActivityDisplayName, Resource, ResultAbout this query
List all AuditLog activities of a user
Sentinel
Explanation
This KQL (Kusto Query Language) query is designed to retrieve and list all audit log activities for a specific user within a specified time frame. Here's a simple breakdown of what the query does:
-
Define Variables:
AccountUPN: This is the user principal name (UPN) of the user whose activities you want to track. In this case, it's set to "[email protected]".SearchWindow: This defines the time period for which you want to search the audit logs. It's set to 48 hours, but you can customize it to any number of hours (h) or days (d).
-
Filter Audit Logs:
- The query searches the
AuditLogstable for entries where theTimeGeneratedis within the last 48 hours (or whatever time frame you set).
- The query searches the
-
Extract User Information:
- It extracts the
InitiatingUserinformation from theInitiatedBy.userfield and then further extracts theuserPrincipalNameto get theInitatingUPN.
- It extracts the
-
Filter by User:
- The query filters the logs to only include entries where the
InitatingUPNmatches the specifiedAccountUPN("[email protected]").
- The query filters the logs to only include entries where the
-
Select and Order Columns:
- Finally, it selects and orders the columns to display:
TimeGenerated,InitatingUPN,OperationName,ResultDescription,ActivityDisplayName,Resource, andResult.
- Finally, it selects and orders the columns to display:
In summary, this query retrieves and displays a list of audit log activities for a specific user within a defined time period, showing key details about each activity.
Details

Bert-Jan Pals
Released: December 1, 2024
Tables
AuditLogs
Keywords
AuditLogsTimeGeneratedInitiatingUserInitatingUPNOperationNameResultDescriptionActivityDisplayNameResourceResult
Operators
letwhereextendparse_jsonproject-reorderago