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
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

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

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...