TH2.10 Entity Pivoting Across Tables
Pivot from indicator to timeline
You have a suspect user from the hunt. You need their complete activity across every M365 data source. The pivot query builds that timeline.
User entity pivot — the universal enrichment query
| |
IP entity pivot — shared infrastructure detection
| |
Application entity pivot — consent abuse investigation
| |
Figure TH2.10 — Entity pivot pattern. Start with the suspect entity. Query every relevant table. Build the chronological timeline.
Try it yourself
Exercise: Build a user timeline
Pick a user from your environment (yourself or a test account). Run the user entity pivot query with a 7-day window. Read the timeline chronologically. Does the activity pattern match your expectation for that user's role?
This exercise builds environmental knowledge (TH0.11) — understanding what a normal user timeline looks like makes anomalous timelines visible during campaigns.
The myth: Running entity pivot queries on specific users during hunting — when no alert has fired — may violate data privacy policies or employee monitoring regulations.
The reality: Threat hunting is a legitimate security function. The pivot is performed on security log data that the organization has lawful basis to process for security purposes (GDPR Article 6(1)(f) — legitimate interests, or the organization’s acceptable use policy). However, the concern is not frivolous. Document why the entity was selected (the hunt hypothesis and the indicator that flagged them) in the hunt record. This documentation demonstrates that the investigation was proportionate and hypothesis-driven, not arbitrary surveillance. TH1.7 (hunt documentation standard) provides this traceability by design.
Extend this approach
The `union` pattern produces a flat timeline. For richer visualization, use Sentinel notebooks (Jupyter + MSTICPy) which can render entity timelines as interactive graphical displays with color-coded events by source. TH16 covers notebook-based hunting. For query-based hunting in Advanced Hunting, the `union | sort by TimeGenerated` pattern is the standard approach used throughout the campaigns.
References Used in This Subsection
- Microsoft. “KQL union Operator.” Microsoft Learn. https://learn.microsoft.com/en-us/kusto/query/union-operator
- Course cross-references: TH1.3 (step 4 — pivot), TH1.4 (behavioral enrichment), TH1.9 (multi-table correlation)
You're reading the free modules of this course
The full course continues with advanced topics, production detection rules, worked investigation scenarios, and deployable artifacts. Premium subscribers get access to all courses.