Splunk Search

Cascaded search with tabular data

drodman29
Path Finder

Given a normal http log I want to be able to use the tabular data (or list) from one search as criteria in a second search.
1) Search host=a or host=b and uri=c | chart count by clientip
2) Search host=a and uri=d and {list of clientIPs from search 1} | chart count by user

I feel sure I'm missing some trick...

Tags (1)
0 Karma
1 Solution

lguinn2
Legend

This is very easy in Splunk

host=a AND uri=d [ search  host=a OR host=b AND uri=c | fields clientip  | dedup clientip ]
| chart count by user 

The part between the brackets [] is called a subsearch. The results of the subsearch are substituted into the outer search string. Use the "search job inspector" if you want to see the intermediate step!

BTW, there are limits to the subsearch. But if your subsearch returns less than a thousand results, you should be fine.

HTH

View solution in original post

lguinn2
Legend

This is very easy in Splunk

host=a AND uri=d [ search  host=a OR host=b AND uri=c | fields clientip  | dedup clientip ]
| chart count by user 

The part between the brackets [] is called a subsearch. The results of the subsearch are substituted into the outer search string. Use the "search job inspector" if you want to see the intermediate step!

BTW, there are limits to the subsearch. But if your subsearch returns less than a thousand results, you should be fine.

HTH

drodman29
Path Finder

Subsearch worked great.

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 ...