The ratio of successful builds to all builds.
The number of successful builds divided by the total number of builds in the given data range.
Data Sources Required
This metric relies on Jenkins builds, GitLab pipelines or GitHub workflow runs.
Data Transformation Required
N/A
SQL Queries
The following SQL shows how to find the success rate of CI builds finished in the given time range.
SELECT 1.0 * sum(case when result = 'SUCCESS' then 1 else 0 end)/ count(*) as "Build Success Rate" FROM cicd_pipelines WHERE $__timeFilter(finished_date) ORDER BY 1
If you want to measure the distribution of CI build result like the donut chart below, please run the following SQL in Grafana.
SELECT result, count(*) as build_count FROM cicd_pipelines WHERE $__timeFilter(finished_date) and id like "%jenkins%" and name in ($job_id) -- the following condition will remove the month with incomplete data and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH) GROUP BY 1 ORDER BY 2 DESC
If you want to measure the mean build success rate per month
in the screenshot below, please run the following SQL in Grafana.
WITH _build_success_rate as( SELECT DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time, result FROM cicd_pipelines WHERE $__timeFilter(finished_date) -- the following condition will remove the month with incomplete data and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH) ) SELECT date_format(time,'%M %Y') as month, 1.0 * sum(case when result = 'SUCCESS' then 1 else 0 end)/ count(*) as "Build Success Rate" FROM _build_success_rate GROUP BY 1 ORDER BY 1