Query Details

MicrosoftGraphActivityLogs User Enrichment

User Enrichment

Query

MicrosoftGraphActivityLogs
| where isnotempty(UserId)
| lookup kind=leftouter (IdentityInfo
    | where TimeGenerated > ago(30d)
    | summarize arg_max(TimeGenerated, *) by AccountObjectId
    | project AccountObjectId, AccountDisplayName, AccountUpn)
    on $left.UserId == $right.AccountObjectId
| project-reorder AccountDisplayName, AccountUpn, RequestMethod, RequestUri

About this query

MicrosoftGraphActivityLogs User Enrichment

Query Information

Description

This query enriches the MicrosoftGraphActivityLogs with userinformation from the IdentityInfo table to get more context in the results.

References

Sentinel

Explanation

This query is designed to enhance the data from the Microsoft Graph Activity Logs by adding user information from another table called IdentityInfo. Here's a simple breakdown of what the query does:

  1. Filter Activity Logs: It starts by selecting entries from the Microsoft Graph Activity Logs where the UserId field is not empty. This ensures that only logs associated with a user are considered.

  2. Enrich with User Information: It performs a left outer join with the IdentityInfo table to add more details about the user. This is done by matching the UserId from the activity logs with the AccountObjectId from the IdentityInfo table.

  3. Recent User Data: From the IdentityInfo table, it only considers records generated in the last 30 days. It selects the most recent entry for each user (using arg_max to get the latest information based on the TimeGenerated field).

  4. Select Relevant User Details: It retrieves specific user details like AccountDisplayName and AccountUpn (User Principal Name) from the IdentityInfo table.

  5. Reorder Columns: Finally, it rearranges the columns in the output to prioritize the display of user information (AccountDisplayName and AccountUpn) followed by request details (RequestMethod and RequestUri).

Overall, this query provides a more comprehensive view of user activities by combining log data with enriched user information.

Details

Bert-Jan Pals profile picture

Bert-Jan Pals

Released: August 14, 2025

Tables

MicrosoftGraphActivityLogsIdentityInfo

Keywords

MicrosoftGraphActivityLogsIdentityInfoUserAccount

Operators

whereisnotemptylookupkind=leftoutersummarizearg_maxbyprojectonproject-reorder

Actions

GitHub