Splunk Search

filtered sub search

athorat3
New Member

Hi

I want to search for Text A on a index and find the Source Files and then on these source files search for Text B
so if Text A is found then Search for B and return Source files.

A and B are separate events in the same source files.

Tags (2)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi athorat3.
let me understand: do you need events where there is TextA and TextB and take the list of source files or do you want to serve events with TextA and then search on the source filenames TextB?
In the first case try:

Index=your_index sourcetype=your_sourcetype TextA TexB 
| stats count by source

in the second case, try:

Index=your_index sourcetype=your_sourcetype TextA 
| fields source 
| search [ search Index=your_index sourcetype=your_sourcetype TexB | rename TextB AS query ] 
| stats count by source 

Bye.
Giuseppe

0 Karma

athorat3
New Member

Thank you for replying back.
yes pretty much the second scenario

When Text A is available then search on the sources for text B

SO . if I see : Project Implemented successfully^ . i need to search for "exit Status 1^"

When I do show source for the event( Project Implemented successfully^ ) I see this which has "exit status 1^" at the end of the file.

^2017-06-21T19:27:01Z|||{node=0001f-*********************************************************/returns: Project Implemented successfully^
^2017-06-21T19:27:01Z|||{node=0001f-node=0001f-
******************************************************/r
^2017-06-21T19:27:01Z|||{node=0001f-node=0001f-
*********************************************************/\
.
.
.
.
.
^2017-06-21T19:27:34Z|nodeend||{executionState=FAILED|failureReason=NonZeroResultCode|node=0001f-idxx02.tableausandbox.com|resultCode=1|step=10|stepctx=10|user=SYSTEM}|Remote command failed with exit status 1^

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi athorat3.
I understood that you wanted search TextB on the names of source files and not on the events: if you want to search TextB in events it's better to use the first scenario because is quicker.

If instead you want to search not all TextB but only TextB that are at the end of each row, you have to use regex command, something like this:

Index=your_index sourcetype=your_sourcetype "Project Implemented successfully" 
| regex "exit\sstatus\s1$"
| ...

Bye.
Giuseppe

0 Karma
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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...