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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...