Splunk Search

How to create a table with duration and job status for jobs that may run more than once a day?

namrithadeepak
Path Finder

Hi,

I have batch job logs that look like below,

alt text

My output needs to look like this,

alt text

The challenge is that the job may fail, in which case it is rerun by another team.
So, in case of job failure, the table should have an entry for success run and one for failure run.

Please help me form the search .

Thanks in advance!!

0 Karma
1 Solution

sundareshr
Legend

Assuming your data is indexed in splunk, try this

index=foo sourcetype=bar ("Starting job" OR "completed successfully" OR "job ended") | rex "JobNameClass:\s?(?<jobclass>\d+)" | rex "(?<completed>Starting|completed|Ending)" | transaction jobclass startswith="Starting Job" endswith="Ending Job" maxevents=3 mvlist=t keepevicted=t | eval endtime=if(mvcount(status)=3, strftime(_time+duration, "%H:%M:%S"), null()) | eval startdate=strftime(_time, "%m/%d/%Y") | eval starttime=strftime(_time, "%H:%M:%S") | eval jobstatus=if(mvcount(status)=3, "Completed", "Failed") | table startdate starttime endtime duration jobstatus

View solution in original post

0 Karma

sundareshr
Legend

Assuming your data is indexed in splunk, try this

index=foo sourcetype=bar ("Starting job" OR "completed successfully" OR "job ended") | rex "JobNameClass:\s?(?<jobclass>\d+)" | rex "(?<completed>Starting|completed|Ending)" | transaction jobclass startswith="Starting Job" endswith="Ending Job" maxevents=3 mvlist=t keepevicted=t | eval endtime=if(mvcount(status)=3, strftime(_time+duration, "%H:%M:%S"), null()) | eval startdate=strftime(_time, "%m/%d/%Y") | eval starttime=strftime(_time, "%H:%M:%S") | eval jobstatus=if(mvcount(status)=3, "Completed", "Failed") | table startdate starttime endtime duration jobstatus
0 Karma

somesoni2
SplunkTrust
SplunkTrust

Can you provide the sample event for condition when the job fails?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...