diff --git a/scripts/dashboards_render_atlas.py b/scripts/dashboards_render_atlas.py index 38308a57..0060c28f 100644 --- a/scripts/dashboards_render_atlas.py +++ b/scripts/dashboards_render_atlas.py @@ -549,6 +549,25 @@ PLATFORM_TEST_SUCCESS_RATE_24H_BY_SUITE = ( f'/ clamp_min((sum by (suite) (increase(platform_quality_gate_runs_total{{suite=~"{PLATFORM_TEST_SUITE_MATCHER}"}}[24h]))), 1)) ' f'and on(suite) ((sum by (suite) (increase(platform_quality_gate_runs_total{{suite=~"{PLATFORM_TEST_SUITE_MATCHER}"}}[24h]))) > 0))' ) +QUALITY_GATE_SUITE_INDEX_30D = ( + f'sum by (suite) (increase(platform_quality_gate_runs_total{{suite=~"{PLATFORM_TEST_SUITE_MATCHER}"}}[30d]))' +) +QUALITY_GATE_COVERAGE_BY_SUITE = ( + '(max by (suite) ({__name__=~".*_quality_gate_coverage_percent"})) ' + 'or on(suite) (max by (suite) (platform_quality_gate_workspace_line_coverage_percent))' +) +QUALITY_GATE_COVERAGE_BY_SUITE_WITH_MISSING = ( + f"({QUALITY_GATE_COVERAGE_BY_SUITE}) or on(suite) (0 * ({QUALITY_GATE_SUITE_INDEX_30D}) - 1)" +) +QUALITY_GATE_COVERAGE_GAP_BY_SUITE = ( + f"clamp_min(95 - ({QUALITY_GATE_COVERAGE_BY_SUITE}), 0)" +) +QUALITY_GATE_SMELL_INFRACTIONS_BY_SUITE = ( + "max by (suite) (platform_quality_gate_source_lines_over_500_total)" +) +QUALITY_GATE_SMELL_INFRACTIONS_BY_SUITE_WITH_MISSING = ( + f"({QUALITY_GATE_SMELL_INFRACTIONS_BY_SUITE}) or on(suite) (0 * ({QUALITY_GATE_SUITE_INDEX_30D}) - 1)" +) PVC_BACKUP_AGE_HOURS_BY_PVC = "sort_desc(max by (namespace, pvc) (pvc_backup_age_hours or on(namespace, pvc) ((1 - pvc_backup_health) * 999)))" ANANKE_SELECTOR = 'job="ananke-power"' ANANKE_UPS_DB_NAME = "Pyrphoros" @@ -3427,6 +3446,16 @@ def build_testing_dashboard(): {"color": "red", "value": 5}, ], } + smell_thresholds = { + "mode": "absolute", + "steps": [ + {"color": "red", "value": None}, + {"color": "green", "value": 0}, + {"color": "yellow", "value": 1}, + {"color": "orange", "value": 3}, + {"color": "red", "value": 5}, + ], + } pass_rate_panel = stat_panel( 1, @@ -3514,6 +3543,77 @@ def build_testing_dashboard(): } suite_panel["description"] = "Trend line per suite. Flat gaps mean no runs in that interval." panels.append(suite_panel) + coverage_panel = bargauge_panel( + 7, + "Quality Gate Coverage by Suite (%, gate 95)", + QUALITY_GATE_COVERAGE_BY_SUITE_WITH_MISSING, + {"h": 8, "w": 12, "x": 0, "y": 24}, + unit="percent", + instant=True, + legend="{{suite}}", + sort_order="asc", + thresholds=pass_rate_thresholds, + decimals=2, + ) + coverage_panel["description"] = ( + "Latest reported per-suite line coverage. The quality gate target is 95%. " + "A value of -1 means that suite has runs but no coverage metric published yet." + ) + coverage_panel["fieldConfig"]["defaults"]["mappings"] = [ + { + "type": "value", + "options": { + "-1": {"text": "missing"}, + }, + } + ] + panels.append(coverage_panel) + coverage_gap_panel = bargauge_panel( + 8, + "Coverage Gap to 95% by Suite", + QUALITY_GATE_COVERAGE_GAP_BY_SUITE, + {"h": 8, "w": 12, "x": 12, "y": 24}, + unit="percent", + instant=True, + legend="{{suite}}", + sort_order="desc", + thresholds={ + "mode": "absolute", + "steps": [ + {"color": "green", "value": None}, + {"color": "yellow", "value": 1}, + {"color": "orange", "value": 5}, + {"color": "red", "value": 10}, + ], + }, + decimals=2, + ) + coverage_gap_panel["description"] = "How far each suite is below the 95% target (0 means at or above target)." + panels.append(coverage_gap_panel) + smell_panel = bargauge_panel( + 9, + "Code Smell Infractions by Suite (files >500 LOC)", + QUALITY_GATE_SMELL_INFRACTIONS_BY_SUITE_WITH_MISSING, + {"h": 8, "w": 24, "x": 0, "y": 32}, + unit="none", + instant=True, + legend="{{suite}}", + sort_order="desc", + thresholds=smell_thresholds, + ) + smell_panel["description"] = ( + "Per-suite count of files violating the 500-line hygiene/code-smell threshold. " + "A value of -1 means that suite has runs but no smell-infraction metric published yet." + ) + smell_panel["fieldConfig"]["defaults"]["mappings"] = [ + { + "type": "value", + "options": { + "-1": {"text": "missing"}, + }, + } + ] + panels.append(smell_panel) return { "uid": "atlas-testing", diff --git a/services/monitoring/dashboards/atlas-testing.json b/services/monitoring/dashboards/atlas-testing.json index 1fc0f569..54af0737 100644 --- a/services/monitoring/dashboards/atlas-testing.json +++ b/services/monitoring/dashboards/atlas-testing.json @@ -443,6 +443,257 @@ } }, "description": "Trend line per suite. Flat gaps mean no runs in that interval." + }, + { + "id": 7, + "type": "bargauge", + "title": "Quality Gate Coverage by Suite (%, gate 95)", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 24 + }, + "targets": [ + { + "expr": "sort(((max by (suite) ({__name__=~\".*_quality_gate_coverage_percent\"})) or on(suite) (max by (suite) (platform_quality_gate_workspace_line_coverage_percent))) or on(suite) (0 * (sum by (suite) (increase(platform_quality_gate_runs_total{suite=~\"ariadne|metis|ananke|atlasbot|lesavka|pegasus|soteria|titan-iac|bstein-home|arcanagon|data-prepper\"}[30d]))) - 1))", + "refId": "A", + "legendFormat": "{{suite}}", + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "percent", + "min": 0, + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "yellow", + "value": 95 + }, + { + "color": "green", + "value": 99 + } + ] + }, + "decimals": 2, + "mappings": [ + { + "type": "value", + "options": { + "-1": { + "text": "missing" + } + } + } + ] + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + } + }, + "transformations": [ + { + "id": "sortBy", + "options": { + "fields": [ + "Value" + ], + "order": "asc" + } + } + ], + "description": "Latest reported per-suite line coverage. The quality gate target is 95%. A value of -1 means that suite has runs but no coverage metric published yet." + }, + { + "id": 8, + "type": "bargauge", + "title": "Coverage Gap to 95% by Suite", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 24 + }, + "targets": [ + { + "expr": "sort_desc(clamp_min(95 - ((max by (suite) ({__name__=~\".*_quality_gate_coverage_percent\"})) or on(suite) (max by (suite) (platform_quality_gate_workspace_line_coverage_percent))), 0))", + "refId": "A", + "legendFormat": "{{suite}}", + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "percent", + "min": 0, + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 1 + }, + { + "color": "orange", + "value": 5 + }, + { + "color": "red", + "value": 10 + } + ] + }, + "decimals": 2 + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + } + }, + "transformations": [ + { + "id": "sortBy", + "options": { + "fields": [ + "Value" + ], + "order": "desc" + } + } + ], + "description": "How far each suite is below the 95% target (0 means at or above target)." + }, + { + "id": 9, + "type": "bargauge", + "title": "Code Smell Infractions by Suite (files >500 LOC)", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 32 + }, + "targets": [ + { + "expr": "sort_desc((max by (suite) (platform_quality_gate_source_lines_over_500_total)) or on(suite) (0 * (sum by (suite) (increase(platform_quality_gate_runs_total{suite=~\"ariadne|metis|ananke|atlasbot|lesavka|pegasus|soteria|titan-iac|bstein-home|arcanagon|data-prepper\"}[30d]))) - 1))", + "refId": "A", + "legendFormat": "{{suite}}", + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "none", + "min": 0, + "max": null, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 0 + }, + { + "color": "yellow", + "value": 1 + }, + { + "color": "orange", + "value": 3 + }, + { + "color": "red", + "value": 5 + } + ] + }, + "mappings": [ + { + "type": "value", + "options": { + "-1": { + "text": "missing" + } + } + } + ] + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + } + }, + "transformations": [ + { + "id": "sortBy", + "options": { + "fields": [ + "Value" + ], + "order": "desc" + } + } + ], + "description": "Per-suite count of files violating the 500-line hygiene/code-smell threshold. A value of -1 means that suite has runs but no smell-infraction metric published yet." } ], "time": { diff --git a/services/monitoring/grafana-dashboard-testing.yaml b/services/monitoring/grafana-dashboard-testing.yaml index 7aa06032..afbfd268 100644 --- a/services/monitoring/grafana-dashboard-testing.yaml +++ b/services/monitoring/grafana-dashboard-testing.yaml @@ -452,6 +452,257 @@ data: } }, "description": "Trend line per suite. Flat gaps mean no runs in that interval." + }, + { + "id": 7, + "type": "bargauge", + "title": "Quality Gate Coverage by Suite (%, gate 95)", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 24 + }, + "targets": [ + { + "expr": "sort(((max by (suite) ({__name__=~\".*_quality_gate_coverage_percent\"})) or on(suite) (max by (suite) (platform_quality_gate_workspace_line_coverage_percent))) or on(suite) (0 * (sum by (suite) (increase(platform_quality_gate_runs_total{suite=~\"ariadne|metis|ananke|atlasbot|lesavka|pegasus|soteria|titan-iac|bstein-home|arcanagon|data-prepper\"}[30d]))) - 1))", + "refId": "A", + "legendFormat": "{{suite}}", + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "percent", + "min": 0, + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "yellow", + "value": 95 + }, + { + "color": "green", + "value": 99 + } + ] + }, + "decimals": 2, + "mappings": [ + { + "type": "value", + "options": { + "-1": { + "text": "missing" + } + } + } + ] + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + } + }, + "transformations": [ + { + "id": "sortBy", + "options": { + "fields": [ + "Value" + ], + "order": "asc" + } + } + ], + "description": "Latest reported per-suite line coverage. The quality gate target is 95%. A value of -1 means that suite has runs but no coverage metric published yet." + }, + { + "id": 8, + "type": "bargauge", + "title": "Coverage Gap to 95% by Suite", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 24 + }, + "targets": [ + { + "expr": "sort_desc(clamp_min(95 - ((max by (suite) ({__name__=~\".*_quality_gate_coverage_percent\"})) or on(suite) (max by (suite) (platform_quality_gate_workspace_line_coverage_percent))), 0))", + "refId": "A", + "legendFormat": "{{suite}}", + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "percent", + "min": 0, + "max": 100, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 1 + }, + { + "color": "orange", + "value": 5 + }, + { + "color": "red", + "value": 10 + } + ] + }, + "decimals": 2 + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + } + }, + "transformations": [ + { + "id": "sortBy", + "options": { + "fields": [ + "Value" + ], + "order": "desc" + } + } + ], + "description": "How far each suite is below the 95% target (0 means at or above target)." + }, + { + "id": 9, + "type": "bargauge", + "title": "Code Smell Infractions by Suite (files >500 LOC)", + "datasource": { + "type": "prometheus", + "uid": "atlas-vm" + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 32 + }, + "targets": [ + { + "expr": "sort_desc((max by (suite) (platform_quality_gate_source_lines_over_500_total)) or on(suite) (0 * (sum by (suite) (increase(platform_quality_gate_runs_total{suite=~\"ariadne|metis|ananke|atlasbot|lesavka|pegasus|soteria|titan-iac|bstein-home|arcanagon|data-prepper\"}[30d]))) - 1))", + "refId": "A", + "legendFormat": "{{suite}}", + "instant": true + } + ], + "fieldConfig": { + "defaults": { + "unit": "none", + "min": 0, + "max": null, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 0 + }, + { + "color": "yellow", + "value": 1 + }, + { + "color": "orange", + "value": 3 + }, + { + "color": "red", + "value": 5 + } + ] + }, + "mappings": [ + { + "type": "value", + "options": { + "-1": { + "text": "missing" + } + } + } + ] + }, + "overrides": [] + }, + "options": { + "displayMode": "gradient", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + } + }, + "transformations": [ + { + "id": "sortBy", + "options": { + "fields": [ + "Value" + ], + "order": "desc" + } + } + ], + "description": "Per-suite count of files violating the 500-line hygiene/code-smell threshold. A value of -1 means that suite has runs but no smell-infraction metric published yet." } ], "time": {