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
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...