Forum Discussion

rpargman's avatar
rpargman
Copper Contributor
Mar 02, 2021
Solved

KQL to extract IP addresses from SecurityAlerts

I'm not sure if there is a simpler way to do this, but I wanted to get a list of all the IP addresses in both Entities and ExtendedProperties of SecurityAlerts. This is helpful to join on DeviceNetwo...
  • TeachJing's avatar
    Mar 05, 2021

    Good stuff ! I modified the query a bit. I think it gets the same results. Also I use distinct just to grab unique IPs. I think that what you were trying to achieve with the summarize make set.

    If you run a "| count" you can see the difference. 

     

    SecurityAlert
    // First get lists of unique IP addresses from the Extended Properties
    | project IPs = tostring(parse_json(ExtendedProperties)["IP Addresses"])
    | extend IPs = split(IPs,",") | mv-expand IPs
    | where isnotempty(IPs) | distinct tostring(IPs) // get only unique IPs
    | union (SecurityAlert // join to Entities IP pool
    | mv-expand parse_json(Entities)
    | project IPs = Entities["Address"]
    | where isnotempty(IPs) | distinct tostring(IPs)) // get only unique IPs
    | order by IPs
    | count

Resources