-
Improvement
-
Resolution: Not A Defect
-
Blocker
-
all
In Prometheus metrics plugin for jenkins, there is no metrics to find the duration of running jobs, or all running jobs, this is required and can be helpful to send alerts or kill such a jobs that perform production critical tasks.
I faced a similar situation and came up with the idea to report it here.
I tried to find may plugins that capture such metrics and also let prometheus scrap it, but honestly could not find one.
I was able to come up with a running groovy code that can fetch the time of runing job in seconds and minutes but want it to be added in this plugin so that prometheus can scrap it.
Code
------------
int MAX_ALLOWED_DURATION_IN_SECONDS = 100 // 6 hours
def busyExecutors = Jenkins.instance.computers
.collect
}
.flatten() // reminder: transforms list(list(executor)) into list(executor)
def ok = true
println "Busy Executors list"
busyExecutors.each { e ->
println e ;
int durationInSeconds = (System.currentTimeMillis() - e.executable.getTimeInMillis())/1000.0
int durationInMinutes = (System.currentTimeMillis() - e.executable.getTimeInMillis())/1000.0/60.0
if(durationInSeconds > MAX_ALLOWED_DURATION_IN_SECONDS)
else
{ println "bye" }}
println "Done"
return ok
--------------------------------------------------
Hi Marky kindly help me in getting this metrics introduced in Prometheus plugin for Jenkins.
Thanks.