From 68bf067281b908eb8d298bc46ff1b663b0e0fdd6 Mon Sep 17 00:00:00 2001 From: "Louis.z" Date: Thu, 10 Oct 2024 17:28:44 +0800 Subject: [PATCH] fix: #8091 sonarqube dashboard (#8137) Co-authored-by: Startrekzky --- grafana/dashboards/Sonarqube.json | 409 +++++++----------------------- 1 file changed, 93 insertions(+), 316 deletions(-) diff --git a/grafana/dashboards/Sonarqube.json b/grafana/dashboards/Sonarqube.json index fc6001d770a..d8708f36d93 100644 --- a/grafana/dashboards/Sonarqube.json +++ b/grafana/dashboards/Sonarqube.json @@ -18,7 +18,6 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": 21, "links": [], "liveNow": false, "panels": [ @@ -50,7 +49,7 @@ "content": "- Use Cases: This dashboard shows the code quality metrics from SonarQube.\n- Data Source Required: SonarQube v8.2+\n- This dashboard does not honor the time filter on the top-right side as SonarQube metrics are all from the latest scan.", "mode": "markdown" }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": { @@ -89,10 +88,7 @@ "type": "row" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "fieldConfig": { "defaults": { "color": { @@ -135,6 +131,7 @@ "graphMode": "area", "justifyMode": "center", "orientation": "vertical", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -142,32 +139,20 @@ "fields": "/.*/", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "value" + "textMode": "value", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, - "rawSql": "SELECT\n count(distinct id) as 'Bugs'\nFROM cq_issues\nWHERE\n project_key in (${project_id})\n and type = 'BUG'\n and severity in (${severity})\n ", + "rawSql": "SELECT\n count(distinct id) as 'Bugs'\nFROM cq_issues\nWHERE\n project_key in (${project_id})\n and type = 'BUG'\n and severity in (${severity})", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -184,27 +169,14 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Reliability", "type": "stat" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "fieldConfig": { "defaults": { "color": { @@ -247,6 +219,7 @@ "graphMode": "area", "justifyMode": "auto", "orientation": "auto", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -254,32 +227,20 @@ "fields": "", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "value" + "textMode": "value", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, "rawSql": "SELECT\n count(distinct id) as 'Vulnerabilities'\nFROM cq_issues\nWHERE\n project_key in (${project_id})\n and type = 'VULNERABILITY'\n and severity in (${severity})", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -296,27 +257,14 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Security", "type": "stat" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "description": "", "fieldConfig": { "defaults": { @@ -360,6 +308,7 @@ "graphMode": "area", "justifyMode": "auto", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -367,32 +316,20 @@ "fields": "/.*/", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, "rawSql": "SELECT\n COUNT(distinct id) AS 'Security Hotspots'\nFROM cq_issues\nWHERE\n project_key in (${project_id})\n and type = 'HOTSPOTS'\n and severity in (${severity})\n", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -409,27 +346,14 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Security Hotspots", "type": "stat" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "description": "", "fieldConfig": { "defaults": { @@ -472,6 +396,7 @@ "graphMode": "area", "justifyMode": "auto", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -479,32 +404,20 @@ "fields": "/.*/", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, "rawSql": "SELECT\n CONCAT(ROUND(COUNT(IF(status != 'TO_REVIEW', id, NULL)) / COUNT(distinct id) * 100, 2), '%') AS 'Reviewed'\nFROM cq_issues\nWHERE\n project_key in (${project_id})\n and type = 'HOTSPOTS'\n and severity in (${severity})", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -521,17 +434,7 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Security Reviewed", @@ -564,10 +467,7 @@ "type": "row" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "description": "", "fieldConfig": { "defaults": { @@ -610,6 +510,7 @@ "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -617,31 +518,20 @@ "fields": "/.*/", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", + "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, "rawSql": "SELECT\n CONCAT(ROUND((sum(lines_to_cover) - sum(uncovered_lines)) / sum(lines_to_cover) * 100, 1), '% ', 'Coverage on ', ROUND(sum(lines_to_cover) / 1000, 0),'k Lines to cover')\nFROM cq_file_metrics\nWHERE\n project_key in (${project_id})\n", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -658,27 +548,14 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Test", "type": "stat" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "description": "", "fieldConfig": { "defaults": { @@ -722,6 +599,7 @@ "graphMode": "area", "justifyMode": "auto", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -729,31 +607,20 @@ "fields": "/.*/", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "value" + "textMode": "value", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", + "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, - "rawSql": "SELECT\n concat(FLOOR(SUM(debt)/8/60), \" day(s) \", FLOOR((SUM(debt)%480)/60), \" hour(s) \") AS 'Debt'\nFROM cq_issues\nWHERE\n project_key in (${project_id})\n and type = 'CODE_SMELL'\n and severity in (${severity})\n ", + "rawSql": "SELECT\n concat(FLOOR(SUM(debt)/8/60), \" day(s) \", FLOOR((SUM(debt)%480)/60), \" hour(s) \") AS 'Debt'\nFROM cq_issues\nWHERE\n project_key in (${project_id})\n and type = 'CODE_SMELL'\n and severity in (${severity})", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -770,27 +637,14 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Maintainability - Debt", "type": "stat" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "description": "", "fieldConfig": { "defaults": { @@ -834,6 +688,7 @@ "graphMode": "area", "justifyMode": "auto", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -841,32 +696,20 @@ "fields": "/.*/", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "value" + "textMode": "value", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, "rawSql": "SELECT\n\tCOUNT(distinct id) as 'Code Smells'\nFROM cq_issues\nWHERE\n project_key in (${project_id})\n and type = 'CODE_SMELL'\n and severity in (${severity})", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -883,17 +726,7 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Maintainability - Code Smells", @@ -926,10 +759,7 @@ "type": "row" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "description": "", "fieldConfig": { "defaults": { @@ -972,6 +802,7 @@ "graphMode": "area", "justifyMode": "auto", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -979,31 +810,20 @@ "fields": "/.*/", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", + "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, - "rawSql": "SELECT\n sum(duplicated_blocks)\nFROM cq_file_metrics\nWHERE\n project_key in (${project_id})\n", + "rawSql": "SELECT\n sum(duplicated_blocks)\nFROM cq_file_metrics\nWHERE\n project_key in (${project_id})", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -1020,27 +840,14 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Duplicated Blocks", "type": "stat" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "description": "", "fieldConfig": { "defaults": { @@ -1083,6 +890,7 @@ "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", + "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" @@ -1090,51 +898,44 @@ "fields": "/.*/", "values": false }, + "showPercentChange": false, "text": {}, - "textMode": "auto" + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", + "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, - "rawSql": "SELECT\n CONCAT(ROUND(sum(duplicated_lines) / sum(num_of_lines) * 100, 1), '% ', 'Duplications on ', ROUND(sum(ncloc) / 1000, 0),'k Lines')\nFROM cq_file_metrics\nWHERE\n project_key in (${project_id})\n", + "rawSql": "SELECT\n CONCAT(ROUND(sum(duplicated_lines) / sum(num_of_lines) * 100, 1), '% ', 'Duplications on ', ROUND(sum(ncloc) / 1000, 0),'k Lines')\nFROM cq_file_metrics\nWHERE\n project_key in (${project_id})", "refId": "A", - "select": [ - [ + "sql": { + "columns": [ { - "params": [ - "blueprint_id" - ], - "type": "column" + "parameters": [], + "type": "function" } - ] - ], - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], "title": "Duplicated Lines", "type": "stat" }, { - "datasource": { - "type": "datasource", - "uid": "-- Mixed --" - }, + "datasource": "mysql", "description": "", "fieldConfig": { "defaults": { @@ -1192,28 +993,15 @@ }, "showHeader": true }, - "pluginVersion": "9.5.15", + "pluginVersion": "11.2.0", "targets": [ { "datasource": "mysql", + "editorMode": "code", "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "queryType": "randomWalk", "rawQuery": true, "rawSql": "SELECT\n\tfile_name, num_of_lines as 'Lines of Code', bugs as 'Bugs', vulnerabilities as 'Vulnerabilities', code_smells as 'Code Smells', \n\tsecurity_hotspots as 'Security Hotspots', CONCAT(ROUND(coverage, 2), '%') as 'Coverage', CONCAT(ROUND(duplicated_lines_density, 2), '%') as 'Duplications'\nFROM cq_file_metrics\nWHERE\n project_key in (${project_id})\nORDER BY bugs desc\nlimit 20", "refId": "A", - "select": [ - [ - { - "params": [ - "blueprint_id" - ], - "type": "column" - } - ] - ], "sql": { "columns": [ { @@ -1230,17 +1018,7 @@ } ], "limit": 50 - }, - "table": "_devlake_blueprint_labels", - "timeColumn": "created_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] + } } ], "title": "Code Quality Metrics by Files (Top 20 order by Bugs)", @@ -1248,8 +1026,7 @@ } ], "refresh": "", - "schemaVersion": 38, - "style": "dark", + "schemaVersion": 39, "tags": [ "Data Source Dashboard", "Stable Data Sources" @@ -1314,8 +1091,8 @@ }, "timepicker": {}, "timezone": "utc", - "title": "SonarQube", + "title": "SonarQube Server", "uid": "WA0qbuJ4k", - "version": 2, + "version": 3, "weekStart": "" } \ No newline at end of file