All Apps and Add-ons

Splunk App for Jenkins: Where can I find examples about creating alerts based on job duration?

mike11339
Explorer

I'm looking for some examples on creating alerts based on job duration. Is this something that can be done with the data?

0 Karma
1 Solution

txiao_splunk
Splunk Employee
Splunk Employee

you can run search like index=jenkins_statistics event_tag=job_event type=completed job_duration>1200 earliest=-1h job_name="*"
(job_duration is measured in seconds, please customize job_duration and job_name for your needs), and then click "Save As", and select Alert
screenshot

Right now job duration is only captured for finished job, if you want to create alert for running jobs, please wait for jenkins plugin v1.4 or try the Snapshot and change the search to index=jenkins_statistics event_tag=slave job_duration earliest=-1h |fields running_builds{}.* |rename running_builds{}.* to * |search job_duration>1200 job_name="*"

View solution in original post

txiao_splunk
Splunk Employee
Splunk Employee

you can run search like index=jenkins_statistics event_tag=job_event type=completed job_duration>1200 earliest=-1h job_name="*"
(job_duration is measured in seconds, please customize job_duration and job_name for your needs), and then click "Save As", and select Alert
screenshot

Right now job duration is only captured for finished job, if you want to create alert for running jobs, please wait for jenkins plugin v1.4 or try the Snapshot and change the search to index=jenkins_statistics event_tag=slave job_duration earliest=-1h |fields running_builds{}.* |rename running_builds{}.* to * |search job_duration>1200 job_name="*"

mike11339
Explorer

The alert for running jobs is exactly what I need. Thanks for taking the time to respond and looking forward to the release of v1.4

0 Karma

txiao_splunk
Splunk Employee
Splunk Employee

1.4.1 released, please try below query

index=jenkins_statistics event_tag=job_monitor host=* earliest=-10m job_duration>3600 job_name=* |stats max(job_duration) as duration by host,build_url

Note: the data is sent every 8 minutes by default.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...