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
Revered Legend

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

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...