In Prometheus recording rules, I want to record the rate of job failure in each of my Jenkins job.
This expression will allow me to do that. Rate of failure for MyJenkinsJob_1.
( sum(jenkins_job_last_build_failed_tests{jobname="MyJenkinsJob_1"})
or (absent(jenkins_job_last_build_failed_tests{jobname="MyJenkinsJob_1"})*0) )
/
( sum(jenkins_job_last_build_total_tests{jobname="MyJenkinsJob_1"})
or (absent(jenkins_job_last_build_total_tests{jobname="MyJenkinJobs_1"})*0) )
Since the logic(equation) is common for all jobs !, I could make use of the same expression by changing the variable value jobname.
Can we do it with some reg expression, so that i don't have to repeatedly hard code(create new rule) the Jenkins job name(eg: MyJenkinsJob_1, MyJenkinsJob_2, MyJenkinsJob_3, ......). Is there any feature available in Prometheus for that !