From 721c268a30178255bb84adf199c3238d9780d5ff Mon Sep 17 00:00:00 2001 From: kpa39l Date: Fri, 2 Oct 2026 18:32:49 +0000 Subject: [PATCH] feat(backup-bigbox): Prometheus rules + Grafana dashboard for BORCH backups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - alerts.yml: группа backup-bigbox — BackupTaskFailed (status!=0), BackupTaskStale (>30h без успеха), BackupMetricsStale (нет прогона >50h) - grafana: дашборд 'Backup BIGBOX' (uid backup-bigbox): статус задач, возраст успеха, длительность, таблица всех задач - provisioning: provider backup → /var/lib/grafana/dashboards/backup - prometheus.yml: job borch (10.8.0.2:19100, node-exporter textfile backup.prom) - Проверено: promtool 13 rules valid; группа загружена после restart; alerts не фолсят --- alerts.yml | 23 ++ grafana/dashboards/backup/backup-bigbox.json | 388 ++++++++++++++++++ .../provisioning/dashboards/dashboards.yml | 11 +- prometheus.yml | 13 + 4 files changed, 434 insertions(+), 1 deletion(-) create mode 100644 grafana/dashboards/backup/backup-bigbox.json diff --git a/alerts.yml b/alerts.yml index 842730b..3b3ba9a 100644 --- a/alerts.yml +++ b/alerts.yml @@ -54,6 +54,29 @@ groups: severity: critical annotations: summary: Vinograd WAN (Ростелеком) {{ $labels.instance }} is down or unreachable +- name: backup-bigbox + rules: + - alert: BackupTaskFailed + expr: backup_status != 0 + for: 2m + labels: + severity: critical + annotations: + summary: Backup task {{ $labels.profile }}/{{ $labels.task }} on bigbox failed (status {{ $value }}) + - alert: BackupTaskStale + expr: (backup_status == 0) and (time() - backup_last_success_timestamp > 30 * 3600) + for: 15m + labels: + severity: warning + annotations: + summary: Backup task {{ $labels.profile }}/{{ $labels.task }} has no successful run for 30h + - alert: BackupMetricsStale + expr: time() - max(backup_last_success_timestamp) > 50 * 3600 + for: 15m + labels: + severity: critical + annotations: + summary: BORCH backup (bigbox) has no successful run for 50h — backup likely did not run - name: vesti rules: - alert: VestiWebDown diff --git a/grafana/dashboards/backup/backup-bigbox.json b/grafana/dashboards/backup/backup-bigbox.json new file mode 100644 index 0000000..6ddd59e --- /dev/null +++ b/grafana/dashboards/backup/backup-bigbox.json @@ -0,0 +1,388 @@ +{ + "annotations": { + "list": [] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 1, + "id": null, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "Prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "0": { + "color": "green", + "text": "OK" + } + }, + "type": "value" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Value" + }, + "properties": [ + { + "id": "custom.width", + "value": 80 + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "11.1.0", + "targets": [ + { + "expr": "backup_status", + "legendFormat": "{{profile}}/{{task}}", + "refId": "A" + } + ], + "title": "Backup task status (bigbox)", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "Prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "hours", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 15, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "line" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 24 + }, + { + "color": "red", + "value": 30 + } + ] + }, + "unit": "h" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 10 + }, + "id": 2, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "expr": "time() - backup_last_success_timestamp", + "legendFormat": "{{profile}}/{{task}}", + "refId": "A" + } + ], + "title": "Last successful backup age (bigbox)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "Prometheus" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "seconds", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "bars", + "fillOpacity": 60, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "s" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 10 + }, + "id": 3, + "options": { + "legend": { + "calcs": [ + "lastNotNull" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "targets": [ + { + "expr": "backup_last_duration_seconds", + "legendFormat": "{{profile}}/{{task}}", + "refId": "A" + } + ], + "title": "Last backup duration (bigbox)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "Prometheus" + }, + "fieldConfig": { + "defaults": { + "custom": { + "filterable": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Status" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "options": { + "0": { + "color": "green", + "text": "OK" + } + }, + "type": "value" + }, + { + "options": { + "from": 1, + "to": 99 + }, + "type": "range" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "color-background", + "type": "number" + } + } + ] + } + ] + }, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 4, + "options": { + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [ + { + "desc": true, + "displayName": "Status" + } + ] + }, + "pluginVersion": "11.1.0", + "targets": [ + { + "expr": "backup_status * on(profile, task) group_left backup_last_duration_seconds", + "format": "table", + "instant": true, + "refId": "A" + } + ], + "title": "All backup tasks (bigbox)", + "type": "table" + } + ], + "refresh": "5m", + "schemaVersion": 39, + "tags": [ + "backup", + "bigbox" + ], + "templating": { + "list": [] + }, + "time": { + "from": "now-24h", + "to": "now" + }, + "timepicker": {}, + "timezone": "utc", + "title": "Backup BIGBOX", + "uid": "backup-bigbox", + "version": 1, + "weekStart": "" +} \ No newline at end of file diff --git a/grafana/provisioning/dashboards/dashboards.yml b/grafana/provisioning/dashboards/dashboards.yml index 1ce01b2..708a3da 100644 --- a/grafana/provisioning/dashboards/dashboards.yml +++ b/grafana/provisioning/dashboards/dashboards.yml @@ -44,4 +44,13 @@ providers: disableDeletion: false updateIntervalSeconds: 30 options: - path: /var/lib/grafana/dashboards/gotosocial \ No newline at end of file + path: /var/lib/grafana/dashboards/gotosocial + + - name: 'backup-dashboards' + orgId: 1 + folder: 'backup' + type: file + disableDeletion: false + updateIntervalSeconds: 30 + options: + path: /var/lib/grafana/dashboards/backup \ No newline at end of file diff --git a/prometheus.yml b/prometheus.yml index 68cd39f..a442033 100644 --- a/prometheus.yml +++ b/prometheus.yml @@ -101,6 +101,19 @@ scrape_configs: regex: 10.8.0.3:9100 target_label: instance replacement: vps03:9100 +- job_name: borch + static_configs: + - targets: + - 10.8.0.2:19100 + labels: + host: bigbox + service: borch-backup + relabel_configs: + - source_labels: + - __address__ + regex: 10.8.0.2:19100 + target_label: instance + replacement: bigbox:19100 - job_name: prometheus static_configs: - targets: