Splunk Search

Search based on response from another search query

stagare
Explorer

First Splunk query gives me a value in a table. The value is a jobId. I want to use this jobId in another search query like a second one. Can we join them in Splunk way?

index=myindex cs2k_transaction_id_in_error="CHG063339403031900 major_code="ERROR" |  rex field=_raw "Job Id: (?<jobId>.*?)\." | table jobId


index=myindex "TTY"  "jobId"

Labels (1)
0 Karma
1 Solution

P_vandereerden
Splunk Employee
Splunk Employee

Ah.
I suspect this is more about the rex expression than the table.

You could try a join:

index=myindex TTY | rex field=_raw "Job Id: (?<jobId>.*?)\."
| join left=L right=R where L.jobId=R.jobId [search
index=myindex cs2k_transaction_id_in_error="CHG063339403031900" major_code="ERROR" | rex field=_raw "Job Id: (?<jobId>.*?)\." | table jobId ]

 

Paul van der Eerden,
Breaking software for over 20 years.

View solution in original post

stagare
Explorer

Thanks for the reply, yes, I have tried that already. It does not work. The response (jobId) is in a table so that wont allow this subsearch.

0 Karma

P_vandereerden
Splunk Employee
Splunk Employee

Ah.
I suspect this is more about the rex expression than the table.

You could try a join:

index=myindex TTY | rex field=_raw "Job Id: (?<jobId>.*?)\."
| join left=L right=R where L.jobId=R.jobId [search
index=myindex cs2k_transaction_id_in_error="CHG063339403031900" major_code="ERROR" | rex field=_raw "Job Id: (?<jobId>.*?)\." | table jobId ]

 

Paul van der Eerden,
Breaking software for over 20 years.

stagare
Explorer

Hi Paul, this join looks to  be working. Thank you very much..

0 Karma

P_vandereerden
Splunk Employee
Splunk Employee

Have you tried a subsearch?

index=myindex "TTY" [ search index=myindex 
  cs2k_transaction_id_in_error="CHG063339403031900 major_code="ERROR" 
  |  rex field=_raw "Job Id: (?<jobId>.*?)\." 
  | table jobId ]
Paul van der Eerden,
Breaking software for over 20 years.
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!

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...