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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...