All Apps and Add-ons

Extract user list and use in next query

MattQ
Explorer

I have a search that returns a number of UserNames. I would like to extract just the usernames [field:UserName] from the search results and then do a follow on search for all the items that have those usernames in them.

Search and return 'ListOfUsers'
Use 'ListOfUsers' to Search index=* (or separate broad search) to return ALL activity from 'ListOfUsers'

0 Karma
1 Solution

alacercogitatus
SplunkTrust
SplunkTrust

Sure.

index=* [ search your_search_for_users | table UserName ] | do_other_things

But.... subsearches are inefficient, since they consume 2 cpus per execution. A nicer way would be to keep a lookup of users, and then use the lookup in the search.

The Saved Search that runs every so often:

index=whatever find_your_users | table UserName | outputlookup interesting_users.csv

Then use it in a "sub-searchy" kind of way.

index=* other_criteria [ | inputlookup interesting_users.csv | table UserName ]

View solution in original post

alacercogitatus
SplunkTrust
SplunkTrust

Sure.

index=* [ search your_search_for_users | table UserName ] | do_other_things

But.... subsearches are inefficient, since they consume 2 cpus per execution. A nicer way would be to keep a lookup of users, and then use the lookup in the search.

The Saved Search that runs every so often:

index=whatever find_your_users | table UserName | outputlookup interesting_users.csv

Then use it in a "sub-searchy" kind of way.

index=* other_criteria [ | inputlookup interesting_users.csv | table UserName ]

David
Splunk Employee
Splunk Employee

This is a great use case for a subsearch. You would have your entire search be:

[search <search criteria for the list of users> | fields UserName] <search for activities>

The subsearch will output a series usernames that are then criteria for the broader search. Make sure you start your subsearch with "search."

0 Karma

MattQ
Explorer

That works to input a field into a more limited search. Is there a way to port those results into a wider search. Like back into index=* UserNameList

0 Karma
Get Updates on the Splunk Community!

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...

Index This | What goes away as soon as you talk about it?

May 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

What's New in Splunk Observability Cloud and Splunk AppDynamics - May 2025

This month, we’re delivering several new innovations in Splunk Observability Cloud and Splunk AppDynamics ...