Creating Entity Mappings from TargetResources sub fields

Copper Contributor

I am creating a rule using the KQL query:

 

AuditLogs
|where OperationName contains "Update group" and TargetResources contains "-x"

 

I get results back and they have the information in I am looking for but how can I then map Entities to the subfields of the TargetResources field, e.g.

 

markscottuk_0-1657807913674.png

 

3 Replies
Doing a Bag_unpack afterwards may also be useful (each entry has its own row after you do)

AuditLogs
| mv-expand TargetResources
| evaluate bag_unpack(TargetResources)

@markscottuk 

This is how to do it with parse_json:

 

AuditLogs
|where OperationName contains "Update group"
| extend DisplayName = tostring(parse_json(TargetResources[0].modifiedProperties[0].displayName))

 

Change the [0] to whaever other number to match the location you want to extract from. And change the displayName to the entry you want.

 

You can use first extract the entry you need, then filter by it in the where expression. In the example below, I am using the displayName to filter for any value:

 

AuditLogs
| extend DisplayName = tostring(parse_json(TargetResources[0].modifiedProperties[0].displayName))
|where OperationName contains "Update group" and DisplayName contains "the value you are looking for"