Splunk Search

Passing Value from Subsearch to Parent Search

jstocker
New Member

I am fairly new to Splunk and only have the basics under my belt at best. I'm having trouble proving out the following use case: 

Taking a malicious URL (threatURL) from email threat (index=emailThreat) events and then querying the firewall (index=firewall) for any user activity including the referenced malicious URL. So far I have the following search:

index=firewall log_subtype=url [search index=emailThreat | dedup threatUrl | table threatUrl] | table time, url, user

Separately, the the two searches work and return the expected value. However, when put together, the search returns no results. Not sure what I'm missing.

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The trick to subsearches is to make sure they return a string that makes sense when it is incorporated into the main search.

Try running the subsearch like this

index=emailThreat | dedup threatUrl | fields threatUrl | format

That will generate the text that the main search will see.  Make sure it looks OK and that the firewall index contains a threatUrl field.  If the field has a different name, add a rename command before format in the subsearch.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

isoutamo
SplunkTrust
SplunkTrust

Hi

can you give sample events from indexes?

Anyhow you could try something like

(index=firewall_los log_subtype=url url=*) OR (index=emailThreath threathUrl=* user=*)
| eval commonUrl=coalesce(url, threathUrl)
| stats first(_time) as _time values(user) as user by commonUrl
| table _time, commonUrl, user
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The trick to subsearches is to make sure they return a string that makes sense when it is incorporated into the main search.

Try running the subsearch like this

index=emailThreat | dedup threatUrl | fields threatUrl | format

That will generate the text that the main search will see.  Make sure it looks OK and that the firewall index contains a threatUrl field.  If the field has a different name, add a rename command before format in the subsearch.

---
If this reply helps you, Karma would be appreciated.
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...