Splunk Search

I need a different way to join two searches

rodolfotva
Engager

Hi, I know this is a hot topic and there is answers everywhere, but i couldn't figure out by my self what to do.

 

Suddenly the join stops work and my search is not performing as spect anymore, nobody from infa gave me a reasonable explanation for that, so i have to figure out a different way .

 

Original Search

 

index=aws-prd-01 application.name=domestic-batch context=BATCH action=SEND_EMAIL  (status=STARTED OR status="NOT RUN")
              | rename status as initialStatus
              | fields jobId initialStatus
              | join type=left jobId [search index=aws-prd-01 application.name=domestic-batch context=BATCH action=SEND_EMAIL (status=COMPLETED OR status=FAILED)
              | rename status as finalStatus | fields jobId finalStatus]
              | table jobId initialStatus finalStatus
              | sort -timestamp

 

 

Original result

jobIdinitialStatusfinalStatus
01STARTEDCOMPLETED
02STARTEDFAILED

 

First search with no changes

 

index=aws-prd-01 application.name=domestic-batch context=BATCH action=SEND_EMAIL  (status=STARTED OR status="NOT RUN") | table jobId, status

 

 

Result

jobIdstatus
01STARTED
02STARTED

 

Second search with no changes

 

index=aws-prd-01 application.name=domestic-batch context=BATCH action=SEND_EMAIL (status=COMPLETED OR status=FAILED) | table jobId, status

 

 

Result

jobIdstatus
01COMPLETED
02FAILED

 

thanks a lot

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You don't say what the current results are for the combined query, but perhaps a different approach will work.  The two searches can be combined into a single search.

index=aws-prd-01 application.name=domestic-batch context=BATCH action=SEND_EMAIL  (status=STARTED OR status="NOT RUN" OR status=COMPLETED OR status=FAILED)
| eval initialStatus = if(status="STARTED" OR status="NOT RUN", status, null()),
       finalStatus = if (status="COMPLETED" OR status="FAILED", status, null())
| stats values(*) as * by jobId
| table jobId initialStatus finalStatus

This search avoids the limitations of join and only touches the index once.

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

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

You don't say what the current results are for the combined query, but perhaps a different approach will work.  The two searches can be combined into a single search.

index=aws-prd-01 application.name=domestic-batch context=BATCH action=SEND_EMAIL  (status=STARTED OR status="NOT RUN" OR status=COMPLETED OR status=FAILED)
| eval initialStatus = if(status="STARTED" OR status="NOT RUN", status, null()),
       finalStatus = if (status="COMPLETED" OR status="FAILED", status, null())
| stats values(*) as * by jobId
| table jobId initialStatus finalStatus

This search avoids the limitations of join and only touches the index once.

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

ITWhisperer
SplunkTrust
SplunkTrust

Try to avoid using join - subsearches are limited

index=aws-prd-01 application.name=domestic-batch context=BATCH action=SEND_EMAIL  (status=STARTED OR status="NOT RUN" OR status=COMPLETED OR status=FAILED)
| eval initialStatus=if(status="STARTED" OR status="NOT RUN", status, null())
| eval finalStatus=if(status="COMPLETED" OR status="FAILED", status, null())
| stats values(initialStatus) as initialStatus values(finalStatus) as finalStatus by jobId
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...

Index This | How many sevens are there between 1 and 100?

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