Splunk Dev

Search for items NOT matching in a lookup from stats table

martincd537
New Member

I have found many answers but none seem to satisfy what I am trying to accomplish.

I am looking through some juniper logs and am making a table of IP's that are talking to a number of hosts. (will have a threshold). But I want to then take those noisy IP's and compare them to a lookup table of mine.

My search:

index=juniper src_ip!=10.10.254.* | stats dc(dest_ip) as IP_Count by src_ip | where IP_Count>50 |

Where would I insert my 'NOT' lookup command or if that is something I would even use?

This works: index=juniper src_ip!=10.10.24.* | stats dc(dest_ip) as IP_Count by src_ip | where IP_Count>50 | lookup server_assets IP_Address as src_ip

But I dont want to see the things listed in this, I want to see the ones that do not match in the lookup.

Any Idears?

Thanks.

Tags (1)
0 Karma
1 Solution

acharlieh
Influencer

If we have your lookup create an additional field, then we can filter and show only those that are not in your lookup (e.g. those that do not have the new field)... Like so:

 <base> | stats ... | where ... | lookup server_assets IP_Address as src_ip OUTPUT IP_Address | where isnull(IP_Address) 

View solution in original post

0 Karma

martincd537
New Member

That is what I ended up doing. Thought there might be a different way. But thank you, I will leave it like that.

Ended up with this:

index=juniper src_ip!=10.10.24.* | stats dc(dest_port) as Port_Count by src_ip | where Port_Count>50 | lookup server_assets IP_Address as src_ip | where isnull(DNSName) | table src_ip Port_Count

0 Karma

acharlieh
Influencer

If we have your lookup create an additional field, then we can filter and show only those that are not in your lookup (e.g. those that do not have the new field)... Like so:

 <base> | stats ... | where ... | lookup server_assets IP_Address as src_ip OUTPUT IP_Address | where isnull(IP_Address) 
0 Karma

martincd537
New Member

That is what I ended up doing. Just from my readings, I thought it may have been a round about way to do it, but gets the job done.

Thanks,

Ended up with this:

index=juniper src_ip!=10.10.24.* | stats dc(dest_port) as Port_Count by src_ip | where Port_Count>50 | lookup server_assets IP_Address as src_ip | where isnull(DNSName) | table src_ip Port_Count

0 Karma
Get Updates on the Splunk Community!

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...

Auto-Injector for Everything Else: Making OpenTelemetry Truly Universal

You might have seen Splunk’s recent announcement about donating the OpenTelemetry Injector to the ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...