I want to use a query in splunk, extract a list of fields and then use these result fields to further filter my subsequent splunk query. How do I do this?
the FORMAT command can be particularly useful for this. This is an overly simplistic example, but should give you an idea of how it's used:
First, craft your subsearch that will give you the fields you care about. Here is a functioning example:
|metadata type=hosts index=_internal | table host | format
Try running this search on it's own to see what the output looks like.
Then we just add it in as a subsearch of your real search:
index=foo sourcetype=bar [|metadata type=hosts index=_internal | table host | format]
that will give you events from index foo, sourcetype bar, and every host from the subsearch.
This is actually an extremely powerful command, as you can use it to dynamically set timeranges as well as complex boolean filters.