Splunk Search

How can I use the result of subquery field as wildcard?

myusufe71
Explorer

I have subquery result as

host1

host2

host2

And I want to put this all host result as host=*  in the main query.

1. subquery

| inputlookup test.csv | search cluster="cluster1" | stats count by host | fields - count

 

2. main query

using subquery, as

index=abc host="*"

host="*" is subquery result.

Or is there any way to extract subquery result as host IN (host1, host2, host3) in main query?

 

Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @myusufe71 ,

let me understand: you want to filter results of the main search with the results of the subsearch, is it correct?

in this case, please, try this:

index=abc [ | inputlookup test.csv WHERE cluster="cluster1" | dedup host | fields host ]

put only attention that the field to use as key (host) is the same in both main and sub search (it's case sensitive!).

Ciao.

Giuseppe

View solution in original post

myusufe71
Explorer

Wow it works. @gcusello you are super duper. Thanks!

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @myusufe71 ,

good for you, see next time!

let me know if I can help you more, or, please, accept one answer for the other people of Community.

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated 😉

gcusello
SplunkTrust
SplunkTrust

Hi @myusufe71 ,

let me understand: you want to filter results of the main search with the results of the subsearch, is it correct?

in this case, please, try this:

index=abc [ | inputlookup test.csv WHERE cluster="cluster1" | dedup host | fields host ]

put only attention that the field to use as key (host) is the same in both main and sub search (it's case sensitive!).

Ciao.

Giuseppe

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...