Splunk Search

How do I write a search with a subsearch?

jb1982
Path Finder

Hey everyone,

Trying to write a search to find Firewall allows by Previous Drops

I am very new to Splunk (love it so far) and am trying to write a search with a subsearch. Basically I want to find IP addresses that were denied at our firewall and then check if they were subsequently allowed at some point. So far I have:

tag=network action=allow [search tag=network NOT action=allow | dedup src_ip | table src_ip] | top src_ip by dest_ip

I think this should be correct but before I mess with it I wanted to see if there was a better way to do this.

Thank you, and sorry for the noobish question!

0 Karma

woodcock
Esteemed Legend

You might use earliest= and latest= to make the 2 parts of your search use different spans.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi jb1982,
Probably you should use different search parameters between main search and subsearch, because if you try to connect two auto exclusive searches you'll not have any results!
In other words with the same search (tag=network) you want to find all src_ips that have at the same time action=allow and action!=allow, not possible!
You should use different search parametrs in main search or in subsearch.
Bye.
Giuseppe

0 Karma

DalJeanis
Legend

Only the src_ip from the subsearch would be passed to the search, so the action!=allow does not affect the main search.

0 Karma

somesoni2
Revered Legend

Looks good to me. May be, in the subsearch, instead of using NOT action=allow, using action=deny or whatever is specific action for deny is. If the possible values of action can be other then allow and deny, you may get some false positive.

cmerriman
Super Champion

either that or try
[search tag=network action!=allow | dedup src_ip | table src_ip|format]

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...