From 33432fc581bbac699b560ba13c97ec4d91dea88c Mon Sep 17 00:00:00 2001 From: Startrekzky Date: Thu, 27 Jun 2024 12:51:14 +0800 Subject: [PATCH] feat: fix CircleCI dashboard SQLs and wording --- grafana/dashboards/CircleCI.json | 110 +++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 20 deletions(-) diff --git a/grafana/dashboards/CircleCI.json b/grafana/dashboards/CircleCI.json index 90ba846f894..69847b9f51b 100644 --- a/grafana/dashboards/CircleCI.json +++ b/grafana/dashboards/CircleCI.json @@ -18,7 +18,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": 24, + "id": 27, "links": [], "liveNow": false, "panels": [ @@ -50,7 +50,7 @@ "content": "- Use Cases: This dashboard shows the basic CI/CD metrics from CircleCI, such as [Build Count](https://devlake.apache.org/docs/Metrics/BuildCount), [Build Duration](https://devlake.apache.org/docs/Metrics/BuildDuration) and [Build Success Rate](https://devlake.apache.org/docs/Metrics/BuildSuccessRate).\n- Data Source Required: CircleCI", "mode": "markdown" }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -108,10 +108,12 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.0.0", "targets": [ { "datasource": "mysql", @@ -120,7 +122,7 @@ "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n count(distinct id)\nFROM \n cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and result = 'SUCCESS'\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n -- the following condition will remove the month with incomplete data\n and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)", + "rawSql": "SELECT\n count(distinct id)\nFROM \n cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and result = 'SUCCESS'\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})", "refId": "A", "select": [ [ @@ -211,10 +213,12 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.0.0", "targets": [ { "datasource": "mysql", @@ -223,7 +227,7 @@ "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n 1.0 * count(case when result = 'SUCCESS' then id else null end)/count(distinct id)\nFROM cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n -- the following condition will remove the month with incomplete data\n and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)", + "rawSql": "SELECT\n 1.0 * count(case when result = 'SUCCESS' then id else null end)/count(distinct id)\nFROM cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})", "refId": "A", "select": [ [ @@ -397,6 +401,7 @@ "values": true }, "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" } @@ -410,7 +415,7 @@ "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n result,\n count(distinct id) as build_count\nFROM cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n -- the following condition will remove the month with incomplete data\n and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)\nGROUP BY 1\nORDER BY 2 desc", + "rawSql": "SELECT\n result,\n count(distinct id) as build_count\nFROM cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\nGROUP BY 1\nORDER BY 2 desc", "refId": "A", "select": [ [ @@ -499,18 +504,21 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.0.0", "targets": [ { "datasource": "mysql", + "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n avg(duration_sec/60) as duration_in_minutes\nFROM cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n -- the following condition will remove the month with incomplete data\n and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)", + "rawSql": "SELECT\n avg(duration_sec/60) as duration_in_minutes\nFROM cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})", "refId": "A", "select": [ [ @@ -522,6 +530,23 @@ } ] ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, "table": "gitlab_commits", "timeColumn": "created_at", "timeColumnType": "timestamp", @@ -546,6 +571,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "Build Count", @@ -615,6 +641,7 @@ "valueSize": 12 }, "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" }, @@ -631,7 +658,7 @@ "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "WITH _builds as(\n SELECT\n DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time,\n count(distinct id) as build_count\n FROM cicd_pipelines\n WHERE\n $__timeFilter(finished_date)\n and result = 'SUCCESS'\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n -- the following condition will remove the month with incomplete data\n and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)\n GROUP BY 1\n)\n\nSELECT \n date_format(time,'%M %Y') as month,\n build_count as \"Build Count\"\nFROM _builds\nORDER BY time\n", + "rawSql": "WITH _builds as(\n SELECT\n DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time,\n count(distinct id) as build_count\n FROM cicd_pipelines\n WHERE\n $__timeFilter(finished_date)\n and result = 'SUCCESS'\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n GROUP BY 1\n)\n\nSELECT \n date_format(time,'%M %Y') as month,\n build_count as \"Workflow Count\"\nFROM _builds\nORDER BY time\n", "refId": "A", "select": [ [ @@ -684,6 +711,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "Workflow Success Rate(%)", @@ -773,6 +801,7 @@ "valueSize": 12 }, "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" }, @@ -788,7 +817,7 @@ "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "WITH _build_success_rate as(\r\n SELECT\r\n DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time,\r\n result,\r\n id\r\n FROM\r\n cicd_pipelines\r\n WHERE\r\n $__timeFilter(finished_date)\r\n and id like \"%circleci%\"\r\n and cicd_scope_id in (${full_name})\r\n -- the following condition will remove the month with incomplete data\r\n and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)\r\n GROUP BY\r\n time, result, id\r\n)\r\n\r\nSELECT \r\n date_format(time,'%M %Y') as month,\r\n 1.0 * sum(case when result = 'SUCCESS' then 1 else 0 end)/ count(*) as \"Build Success Rate\"\r\nFROM _build_success_rate\r\nGROUP BY 1\r\nORDER BY 1", + "rawSql": "WITH _build_success_rate as(\r\n SELECT\r\n DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time,\r\n result,\r\n id\r\n FROM\r\n cicd_pipelines\r\n WHERE\r\n $__timeFilter(finished_date)\r\n and id like \"%circleci%\"\r\n and cicd_scope_id in (${full_name})\r\n GROUP BY\r\n time, result, id\r\n)\r\n\r\nSELECT \r\n date_format(time,'%M %Y') as month,\r\n 1.0 * sum(case when result = 'SUCCESS' then 1 else 0 end)/ count(*) as \"Workflow Success Rate\"\r\nFROM _build_success_rate\r\nGROUP BY 1\r\nORDER BY 1", "refId": "A", "select": [ [ @@ -841,6 +870,7 @@ "mode": "fixed" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "Build Count", @@ -854,6 +884,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 4, @@ -942,6 +973,7 @@ "showLegend": true }, "tooltip": { + "maxHeight": 600, "mode": "multi", "sort": "none" } @@ -950,12 +982,13 @@ "targets": [ { "datasource": "mysql", + "editorMode": "code", "format": "time_series", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time,\n count(distinct case when result = 'SUCCESS' then id else null end) as successful_build_count,\n count(distinct case when result != 'SUCCESS' then id else null end) as failed_build_count\nFROM cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n -- the following condition will remove the month with incomplete data\n and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)\nGROUP BY 1", + "rawSql": "SELECT\n DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time,\n count(distinct case when result = 'SUCCESS' then id else null end) as successful_workflow_count,\n count(distinct case when result != 'SUCCESS' then id else null end) as failed_workflow_count\nFROM cicd_pipelines\nWHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\nGROUP BY 1", "refId": "A", "select": [ [ @@ -967,6 +1000,23 @@ } ] ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, "table": "ae_projects", "timeColumn": "ae_create_time", "timeColumnType": "timestamp", @@ -991,6 +1041,7 @@ "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "Build Count", @@ -1076,6 +1127,7 @@ "valueSize": 12 }, "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" }, @@ -1086,12 +1138,13 @@ "targets": [ { "datasource": "mysql", + "editorMode": "code", "format": "table", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "WITH _builds as(\n SELECT\n DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time,\n avg(duration_sec) as mean_duration_sec\n FROM \n cicd_pipelines\n WHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n -- the following condition will remove the month with incomplete data\n and finished_date >= DATE_ADD(DATE_ADD($__timeFrom(), INTERVAL -DAY($__timeFrom())+1 DAY), INTERVAL +1 MONTH)\n GROUP BY 1\n)\n\nSELECT \n date_format(time,'%M %Y') as month,\n mean_duration_sec/60 as mean_duration_minutes\nFROM _builds\nORDER BY time\n", + "rawSql": "WITH _builds as(\n SELECT\n DATE_ADD(date(finished_date), INTERVAL -DAYOFMONTH(date(finished_date))+1 DAY) as time,\n avg(duration_sec) as mean_duration_sec\n FROM \n cicd_pipelines\n WHERE\n $__timeFilter(finished_date)\n and id like \"%circleci%\"\n and cicd_scope_id in (${full_name})\n GROUP BY 1\n)\n\nSELECT \n date_format(time,'%M %Y') as month,\n mean_duration_sec/60 as mean_duration_minutes\nFROM _builds\nORDER BY time\n", "refId": "A", "select": [ [ @@ -1103,6 +1156,23 @@ } ] ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, "table": "ae_projects", "timeColumn": "ae_create_time", "timeColumnType": "timestamp", @@ -1139,7 +1209,7 @@ "content": "
\n\nThis dashboard is created based on this [data schema](https://devlake.apache.org/docs/DataModels/DevLakeDomainLayerSchema). Want to add more metrics? Please follow the [guide](https://devlake.apache.org/docs/Configuration/Dashboards/GrafanaUserGuide).", "mode": "markdown" }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -1154,8 +1224,7 @@ } ], "refresh": "", - "schemaVersion": 38, - "style": "dark", + "schemaVersion": 39, "tags": [ "Data Source Dashboard" ], @@ -1192,10 +1261,11 @@ "from": "now-6M", "to": "now" }, + "timeRangeUpdatedDuringEditOrView": false, "timepicker": {}, "timezone": "", "title": "CircleCI", "uid": "CircleCI", - "version": 2, + "version": 3, "weekStart": "" } \ No newline at end of file