Splunk Search

Pass the result of one query to another

anjihari
Observer

I have the first query

First Query :     search criteria | rex field=_raw ".* IPAddress=(?<IPAddress>.+?) " | table IPAddress

The above query is returning a table with all IPAddress. I want this data to be looked at in the second query. How can we write two queries as single?

Second Query :   search criteria  | rex field=_raw ".* IPAddress=(?<IPAddress>.+?)\"" | where IPAddress in (first Query results )  | rex field=_raw ".* value=(?<value>.+?)\"" | table IPAddress,value, _time

I tried below but it is empty results

<first search > | rex field=_raw ".* IPAddress=(?<IPAddress>.+?)\"" | where IPAddress in ([search <second search> | rex field=_raw ".* IPAddress=(?<IPAddress>.+?) "
| fields IPAddress ])| rex field=_raw ".* value=(?<value>.+?)\"" | table IPAddress,value, _time

 

Labels (4)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

There is no "passing" of results in a query, except via pipe.  You may be able to get a subsearch (like you already tried) to work, but we'd need to see the "search criteria" as that has a big effect on how the searches are combined.

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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

Accelerating Observability as Code with the Splunk AI Assistant

We’ve seen in previous posts what Observability as Code (OaC) is and how it’s now essential for managing ...