From ea1622ffa94a076fa2eba47f5ce1bca934c69ab6 Mon Sep 17 00:00:00 2001 From: Sergei Poljanski Date: Tue, 17 Nov 2026 12:32:28 +0400 Subject: [PATCH] grafana: Deploys dashboard for comin One row per host: deployed commit (linked to Forgejo), last deployment, whether the head of main is signed or still waiting, failing stages, reboot needed, suspended, last activation. Below: the stage and head history, fetch rate, activations, and comin's log from Loki. Assisted-by: Claude:opus-5-5 --- .../dashboards/Infrastructure/deploys.json | 765 ++++++++++++++++++ 1 file changed, 765 insertions(+) create mode 100644 nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/deploys.json diff --git a/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/deploys.json b/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/deploys.json new file mode 100644 index 0000000..46c9a74 --- /dev/null +++ b/nixos/hosts/asxpio-ops/monitoring/dashboards/Infrastructure/deploys.json @@ -0,0 +1,765 @@ +{ + "uid": "asxpio-deploys", + "title": "Deploys", + "tags": [ + "comin", + "nixos" + ], + "schemaVersion": 39, + "version": 1, + "editable": true, + "refresh": "1m", + "time": { + "from": "now-24h", + "to": "now" + }, + "description": "comin on each host: what is deployed, whether main is signed, failures, and its log.", + "templating": { + "list": [ + { + "name": "host", + "type": "query", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "query": { + "query": "label_values(comin_build_info, host)", + "refId": "host" + }, + "includeAll": true, + "multi": true, + "current": { + "text": "All", + "value": "$__all" + }, + "refresh": 2 + } + ] + }, + "links": [ + { + "title": "iac commits", + "url": "https://git.asxp.io/asxpi/iac/commits/branch/main", + "type": "link", + "targetBlank": true + } + ], + "panels": [ + { + "type": "table", + "title": "Hosts", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 0 + }, + "description": "What each host runs (comin). Deployed: the last commit comin switched to; a commit that leaves a host's system unchanged is not switched to, so this can lag main. Head signed / waiting refer to the head of main.", + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "comin_deployment_info{host=~\"$host\"}", + "format": "table", + "instant": true, + "range": false + }, + { + "refId": "B", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "comin_main_signed{host=~\"$host\"}", + "format": "table", + "instant": true, + "range": false + }, + { + "refId": "C", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "comin_main_pending{host=~\"$host\"}", + "format": "table", + "instant": true, + "range": false + }, + { + "refId": "D", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "max by (host) ({__name__=~\"comin_last_(fetch|eval|build|deployment)_failed\", host=~\"$host\"})", + "format": "table", + "instant": true, + "range": false + }, + { + "refId": "E", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "comin_need_to_reboot{host=~\"$host\"}", + "format": "table", + "instant": true, + "range": false + }, + { + "refId": "F", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "comin_is_suspended{host=~\"$host\"}", + "format": "table", + "instant": true, + "range": false + }, + { + "refId": "G", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "nixos_activation_timestamp_seconds{host=~\"$host\"} * 1000", + "format": "table", + "instant": true, + "range": false + } + ], + "transformations": [ + { + "id": "merge", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": { + "Time": true, + "__name__": true, + "instance": true, + "job": true, + "Value #A": true + }, + "indexByName": { + "host": 0, + "commit_id": 1, + "status": 2, + "Value #B": 3, + "Value #C": 4, + "Value #D": 5, + "Value #E": 6, + "Value #F": 7, + "Value #G": 8 + } + } + } + ], + "fieldConfig": { + "defaults": { + "custom": { + "align": "left" + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "host" + }, + "properties": [ + { + "id": "displayName", + "value": "Host" + }, + { + "id": "custom.width", + "value": 150 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "commit_id" + }, + "properties": [ + { + "id": "displayName", + "value": "Deployed commit" + }, + { + "id": "custom.width", + "value": 340 + }, + { + "id": "links", + "value": [ + { + "title": "Commit", + "url": "https://git.asxp.io/asxpi/iac/commit/${__value.raw}", + "targetBlank": true + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "status" + }, + "properties": [ + { + "id": "displayName", + "value": "Last deployment" + }, + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "done": { + "text": "done", + "color": "green" + }, + "failed": { + "text": "FAILED", + "color": "red" + }, + "running": { + "text": "running", + "color": "blue" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 140 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value #B" + }, + "properties": [ + { + "id": "displayName", + "value": "Head signed" + }, + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "0": { + "text": "NO", + "color": "red" + }, + "1": { + "text": "yes", + "color": "green" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 120 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value #C" + }, + "properties": [ + { + "id": "displayName", + "value": "Waiting" + }, + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "0": { + "text": "no", + "color": "green" + }, + "1": { + "text": "YES", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 100 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value #D" + }, + "properties": [ + { + "id": "displayName", + "value": "Failing" + }, + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "0": { + "text": "no", + "color": "green" + }, + "1": { + "text": "YES", + "color": "red" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 100 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value #E" + }, + "properties": [ + { + "id": "displayName", + "value": "Needs reboot" + }, + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "0": { + "text": "no", + "color": "green" + }, + "1": { + "text": "yes", + "color": "orange" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 120 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value #F" + }, + "properties": [ + { + "id": "displayName", + "value": "Suspended" + }, + { + "id": "mappings", + "value": [ + { + "type": "value", + "options": { + "0": { + "text": "no", + "color": "green" + }, + "1": { + "text": "yes", + "color": "orange" + } + } + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "custom.width", + "value": 110 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Value #G" + }, + "properties": [ + { + "id": "displayName", + "value": "Last activation" + }, + { + "id": "unit", + "value": "dateTimeFromNow" + } + ] + } + ] + }, + "options": { + "showHeader": true, + "cellHeight": "sm" + } + }, + { + "type": "state-timeline", + "title": "comin stages failing", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 5 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "{__name__=~\"comin_last_(fetch|eval|build|deployment)_failed\", host=~\"$host\"}", + "format": "time_series", + "instant": false, + "range": true, + "legendFormat": "{{host}} {{__name__}}" + } + ], + "transformations": [ + { + "id": "renameByRegex", + "options": { + "regex": "(.*) comin_last_(.*)_failed", + "renamePattern": "$1 $2" + } + } + ], + "fieldConfig": { + "defaults": { + "mappings": [ + { + "type": "value", + "options": { + "0": { + "text": "ok", + "color": "green" + }, + "1": { + "text": "failed", + "color": "red" + } + } + } + ], + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "showValue": "never", + "mergeValues": true, + "rowHeight": 0.8, + "legend": { + "showLegend": false + } + } + }, + { + "type": "state-timeline", + "title": "Head of main", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 5 + }, + "description": "Signed: carries a trusted signature, so comin may deploy it. Waiting: not yet evaluated by comin (alerts after 30 minutes).", + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "comin_main_signed{host=~\"$host\"}", + "format": "time_series", + "instant": false, + "range": true, + "legendFormat": "{{host}} signed" + }, + { + "refId": "B", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "1 - comin_main_pending{host=~\"$host\"}", + "format": "time_series", + "instant": false, + "range": true, + "legendFormat": "{{host}} evaluated" + } + ], + "fieldConfig": { + "defaults": { + "mappings": [ + { + "type": "value", + "options": { + "1": { + "text": "yes", + "color": "green" + }, + "0": { + "text": "NO", + "color": "red" + } + } + } + ], + "color": { + "mode": "thresholds" + }, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "options": { + "showValue": "never", + "mergeValues": true, + "rowHeight": 0.8, + "legend": { + "showLegend": false + } + } + }, + { + "type": "timeseries", + "title": "Fetches per minute", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 12 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "sum by (host, status) (rate(comin_fetch_count{host=~\"$host\"}[5m])) * 60", + "format": "time_series", + "instant": false, + "range": true, + "legendFormat": "{{host}} {{status}}" + } + ], + "fieldConfig": { + "defaults": { + "unit": "none", + "custom": { + "drawStyle": "line", + "fillOpacity": 10 + } + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "type": "timeseries", + "title": "Activations", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 12 + }, + "description": "NixOS activations: deploys and boots.", + "targets": [ + { + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "expr": "changes(nixos_activation_timestamp_seconds{host=~\"$host\"}[$__interval]) > 0", + "format": "time_series", + "instant": false, + "range": true, + "legendFormat": "{{host}}" + } + ], + "fieldConfig": { + "defaults": { + "custom": { + "drawStyle": "bars", + "fillOpacity": 80 + }, + "decimals": 0 + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "type": "logs", + "title": "comin log", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 19 + }, + "targets": [ + { + "refId": "A", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "expr": "{job=\"journal\", unit=\"comin.service\", host=~\"$host\"} !~ \"scheduler: |confirmer: \"" + } + ], + "options": { + "showTime": true, + "wrapLogMessage": true, + "sortOrder": "Descending", + "enableLogDetails": true + } + } + ] +}