A cloud-native SIEM solution that provides intelligent security analytics and threat detection across systems
Hi @GuyP Dubois , unfortunately Kusto does not support recursion. You'd have to do it by iteratively expanding the hierarchy using a series of union operations or by leveraging a materialized view if you are able to preprocess the data.
For a high-level overview:
- Start by defining the initial set of employees who directly report to the given supervisor.
- Iteratively find employees who report to the employees found in the previous step.
- Continue this until no more employees are found.
For example:
let SupervisorID = 1;
let Level1 = Employees
| where DirectSupervisorID == SupervisorID;
let Level2 = Employees
| where DirectSupervisorID in (Level1 | project EmployeeID);
let Level3 = Employees
| where DirectSupervisorID in (Level2 | project EmployeeID);
let Level4 = Employees
| where DirectSupervisorID in (Level3 | project EmployeeID);
// Add more levels as needed, up to a reasonable maximum depth.
union Level1, Level2, Level3, Level4
| distinct Name, EmployeeID, DirectSupervisorID
Level1 retrieves employees directly supervised by Alice (SupervisorID = 1). Level2 retrieves employees supervised by anyone in Level1, and so on. You can add more levels if necessary, though this approach may not scale well for very deep or very wide hierarchies.
For a more dynamic approach, you might consider using a loop or a stored procedure in a more traditional programming environment, preprocess the data, and then load it into Sentinel.
Please let me know if you have any questions and I can help you further.
If this answer helps you please mark "Accept Answer" so other users can reference it.
Thank you,
James