Let me see if I can restate the requirement correctly: if IP values for a given Hostname overlap in the two lookups, that's a match unless lookup A contains only one single IP. A mismatch happens i...
See more...
Let me see if I can restate the requirement correctly: if IP values for a given Hostname overlap in the two lookups, that's a match unless lookup A contains only one single IP. A mismatch happens if there is zero overlap of IP for a Hostname in the two, or if lookup A contains a single IP for that Hostname. Mathematically, this translates into a test of unique values because if there is any overlap, total number of unique IPs must be smaller than the sum of unique IPs in each lookup. Hence | inputlookup lookup_A
| stats values(IP) as IP_A by Hostname
| inputlookup lookup_B append=true
| stats values(IP) as IP_B by Hostname
| eval IP = coalesce(IP_A, IP_B)
| stats values(IP_A) as IP_A values(IP_B) as IP_B values(IP) as IP by Hostname
| eval match = if(mvcount(IP_A) == 1 OR mvcount(IP) == mvcount(IP_A) + mvcount(IP_B), "no", "yes") Your sample data gives Hostname IP_A IP_B IP match Host A 10.10.10.1 10.10.10.2 10.10.10.1 10.10.10.1 10.10.10.2 yes Host B 172.1.1.1 172.1.1.1 172.1.1.2 172.1.1.1 172.1.1.2 no Below is an emulation that you can play with and compare with real data | makeresults
| eval _raw = "Hostname,IP
Host A,10.10.10.1
Host A,10.10.10.2
Host B,172.1.1.1"
| multikv forceheader=1
| fields - _* linecount
| stats values(IP) as IP_A by Hostname
``` above emulates
| inputlookup lookup_A
| stats values(IP) as IP_A by Hostname
```
| append
[| makeresults
| eval _raw = "Hostname,IP
Host A,10.10.10.1
Host B,172.1.1.1
Host B,172.1.1.2"
| multikv forceheader=1
| fields - _* linecount
| stats values(IP) as IP_B by Hostname]
``` subsearch emulates
| inputlookup lookup_B append=true
| stats values(IP) as IP_B by Hostname
```
| eval IP = coalesce(IP_A, IP_B)
| stats values(IP_A) as IP_A values(IP_B) as IP_B values(IP) as IP by Hostname
| eval match = if(mvcount(IP_A) == 1 OR mvcount(IP) == mvcount(IP_A) + mvcount(IP_B), "no", "yes")