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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...