Compare commits
3 Commits
41a1075b91
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ae180c799 | |||
| 1803833b50 | |||
| ec779b6ece |
@@ -9,3 +9,4 @@ vaults/*
|
||||
# Reports: artefacto local, no se versiona (ver .claude/rules/reports.md)
|
||||
reports/*
|
||||
!reports/.gitkeep
|
||||
!vaults/vault.yaml
|
||||
|
||||
@@ -4,10 +4,26 @@
|
||||
"tags": ["fleet"],
|
||||
"timezone": "browser",
|
||||
"schemaVersion": 39,
|
||||
"version": 2,
|
||||
"version": 3,
|
||||
"refresh": "15s",
|
||||
"time": { "from": "now-3h", "to": "now" },
|
||||
"templating": { "list": [] },
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"name": "role",
|
||||
"label": "Rol",
|
||||
"type": "query",
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"query": "label_values(node_uptime_seconds, role)",
|
||||
"refresh": 2,
|
||||
"includeAll": true,
|
||||
"multi": true,
|
||||
"allValue": ".*",
|
||||
"current": { "text": ["All"], "value": ["$__all"] },
|
||||
"sort": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
@@ -15,7 +31,7 @@
|
||||
"title": "Nodos reportando",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 0, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "count(group by(instance) (last_over_time(node_uptime_seconds[2m])))", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "count(group by(instance) (last_over_time(node_uptime_seconds{role=~\"$role\"}[2m])))", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "none", "color": { "mode": "fixed", "fixedColor": "green" } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "value", "graphMode": "none", "textMode": "value" }
|
||||
},
|
||||
@@ -25,7 +41,7 @@
|
||||
"title": "Nodos caídos",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 4, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "(max_over_time((count(group by(instance) (last_over_time(node_uptime_seconds[2m]))))[24h:1m])) - count(group by(instance) (last_over_time(node_uptime_seconds[2m])))", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "(max_over_time((count(group by(instance) (last_over_time(node_uptime_seconds{role=~\"$role\"}[2m]))))[24h:1m])) - count(group by(instance) (last_over_time(node_uptime_seconds{role=~\"$role\"}[2m])))", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "none", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 1 } ] } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "background", "graphMode": "none", "textMode": "value" }
|
||||
},
|
||||
@@ -35,7 +51,7 @@
|
||||
"title": "CPU máx",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 8, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "max(node_cpu_percent)", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "max(node_cpu_percent{role=~\"$role\"})", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 70 }, { "color": "red", "value": 90 } ] } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area" }
|
||||
},
|
||||
@@ -45,7 +61,7 @@
|
||||
"title": "RAM máx",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 12, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "max(node_mem_used_percent)", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "max(node_mem_used_percent{role=~\"$role\"})", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 75 }, { "color": "red", "value": 90 } ] } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area" }
|
||||
},
|
||||
@@ -55,7 +71,7 @@
|
||||
"title": "Disco máx",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 16, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "max(node_disk_used_percent)", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "max(node_disk_used_percent{role=~\"$role\"})", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "yellow", "value": 80 }, { "color": "red", "value": 90 } ] } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area" }
|
||||
},
|
||||
@@ -65,7 +81,7 @@
|
||||
"title": "Load máx",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 20, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "max(node_load1)", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "max(node_load1{role=~\"$role\"})", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "short", "color": { "mode": "fixed", "fixedColor": "blue" } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "value", "graphMode": "area" }
|
||||
},
|
||||
@@ -75,7 +91,7 @@
|
||||
"title": "CPU % por nodo",
|
||||
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 4 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "node_cpu_percent", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "node_cpu_percent{role=~\"$role\"}", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100, "custom": { "drawStyle": "line", "fillOpacity": 10, "showPoints": "never", "lineWidth": 2 } }, "overrides": [] },
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["lastNotNull", "max"] }, "tooltip": { "mode": "multi", "sort": "desc" } }
|
||||
},
|
||||
@@ -85,7 +101,7 @@
|
||||
"title": "RAM % por nodo",
|
||||
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 4 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "node_mem_used_percent", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "node_mem_used_percent{role=~\"$role\"}", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100, "custom": { "drawStyle": "line", "fillOpacity": 10, "showPoints": "never", "lineWidth": 2 } }, "overrides": [] },
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["lastNotNull", "max"] }, "tooltip": { "mode": "multi", "sort": "desc" } }
|
||||
},
|
||||
@@ -95,7 +111,7 @@
|
||||
"title": "Load 1m por nodo",
|
||||
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 10 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "node_load1", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "node_load1{role=~\"$role\"}", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "short", "min": 0, "custom": { "drawStyle": "line", "fillOpacity": 10, "showPoints": "never", "lineWidth": 2 } }, "overrides": [] },
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["lastNotNull", "max"] }, "tooltip": { "mode": "multi", "sort": "desc" } }
|
||||
},
|
||||
@@ -105,7 +121,7 @@
|
||||
"title": "Disco usado % (máx por nodo)",
|
||||
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 10 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "max by(instance) (node_disk_used_percent)", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "max by(instance) (node_disk_used_percent{role=~\"$role\"})", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100, "custom": { "drawStyle": "line", "fillOpacity": 10, "showPoints": "never", "lineWidth": 2 } }, "overrides": [] },
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["lastNotNull", "max"] }, "tooltip": { "mode": "multi", "sort": "desc" } }
|
||||
},
|
||||
@@ -115,7 +131,7 @@
|
||||
"title": "Red recibida (sum por nodo)",
|
||||
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 16 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "sum by(instance) (rate(node_net_recv_bytes[2m]))", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "sum by(instance) (rate(node_net_recv_bytes{role=~\"$role\"}[2m]))", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "Bps", "min": 0, "custom": { "drawStyle": "line", "fillOpacity": 10, "showPoints": "never", "lineWidth": 2 } }, "overrides": [] },
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["lastNotNull", "max"] }, "tooltip": { "mode": "multi", "sort": "desc" } }
|
||||
},
|
||||
@@ -125,7 +141,7 @@
|
||||
"title": "Red enviada (sum por nodo)",
|
||||
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 16 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "sum by(instance) (rate(node_net_sent_bytes[2m]))", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"targets": [ { "refId": "A", "expr": "sum by(instance) (rate(node_net_sent_bytes{role=~\"$role\"}[2m]))", "legendFormat": "{{instance}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "Bps", "min": 0, "custom": { "drawStyle": "line", "fillOpacity": 10, "showPoints": "never", "lineWidth": 2 } }, "overrides": [] },
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["lastNotNull", "max"] }, "tooltip": { "mode": "multi", "sort": "desc" } }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
{
|
||||
"uid": "unibus-cluster",
|
||||
"title": "unibus — Cluster",
|
||||
"tags": ["fleet", "unibus"],
|
||||
"timezone": "browser",
|
||||
"schemaVersion": 39,
|
||||
"version": 1,
|
||||
"refresh": "30s",
|
||||
"time": { "from": "now-6h", "to": "now" },
|
||||
"templating": { "list": [] },
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "stat",
|
||||
"title": "Nodos up",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 0, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "sum(last_over_time(unibus_up[2m]))", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "none", "color": { "mode": "fixed", "fixedColor": "green" } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "value", "graphMode": "none", "textMode": "value" }
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "stat",
|
||||
"title": "Cluster size (esperado)",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 4, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "max(last_over_time(unibus_cluster_size[5m]))", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "none", "color": { "mode": "fixed", "fixedColor": "blue" } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "value", "graphMode": "none", "textMode": "value" }
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "stat",
|
||||
"title": "Nodos caídos",
|
||||
"gridPos": { "h": 4, "w": 4, "x": 8, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "max(last_over_time(unibus_cluster_size[5m])) - sum(last_over_time(unibus_up[2m]))", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "none", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 1 } ] } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "background", "graphMode": "none", "textMode": "value" }
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "stat",
|
||||
"title": "Posture homogénea segura",
|
||||
"gridPos": { "h": 4, "w": 6, "x": 12, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "min(last_over_time(unibus_posture_enforce[2m])) * min(last_over_time(unibus_posture_acl[2m])) * min(last_over_time(unibus_posture_tls[2m])) * min(last_over_time(unibus_posture_cluster[2m])) * min(last_over_time(unibus_store_kv[2m]))", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "none", "mappings": [ { "type": "value", "options": { "0": { "text": "DEGRADADA", "color": "red" }, "1": { "text": "OK (enforce+acl+tls+cluster+kv)", "color": "green" } } } ], "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "green", "value": 1 } ] } }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "background", "graphMode": "none", "textMode": "value" }
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "stat",
|
||||
"title": "Meta-leader",
|
||||
"gridPos": { "h": 4, "w": 6, "x": 18, "y": 0 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "unibus_meta_leader == 1", "legendFormat": "{{node}}", "instant": true, "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "none", "color": { "mode": "fixed", "fixedColor": "purple" }, "noValue": "n/d (requiere métricas NATS)" }, "overrides": [] },
|
||||
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "colorMode": "none", "graphMode": "none", "textMode": "name" }
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"type": "timeseries",
|
||||
"title": "up / down por nodo",
|
||||
"gridPos": { "h": 7, "w": 12, "x": 0, "y": 4 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "unibus_up", "legendFormat": "{{node}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "none", "min": 0, "max": 1, "custom": { "drawStyle": "line", "fillOpacity": 25, "showPoints": "never", "lineWidth": 2, "lineInterpolation": "stepAfter", "spanNulls": false } }, "overrides": [] },
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["lastNotNull"] }, "tooltip": { "mode": "multi", "sort": "desc" } }
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"type": "state-timeline",
|
||||
"title": "Matriz de posture por nodo (enforce / acl / tls / cluster / store-kv)",
|
||||
"gridPos": { "h": 9, "w": 12, "x": 12, "y": 4 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [
|
||||
{ "refId": "A", "expr": "unibus_posture_enforce", "legendFormat": "{{node}} · enforce", "datasource": { "type": "prometheus", "uid": "victoriametrics" } },
|
||||
{ "refId": "B", "expr": "unibus_posture_acl", "legendFormat": "{{node}} · acl", "datasource": { "type": "prometheus", "uid": "victoriametrics" } },
|
||||
{ "refId": "C", "expr": "unibus_posture_tls", "legendFormat": "{{node}} · tls", "datasource": { "type": "prometheus", "uid": "victoriametrics" } },
|
||||
{ "refId": "D", "expr": "unibus_posture_cluster", "legendFormat": "{{node}} · cluster", "datasource": { "type": "prometheus", "uid": "victoriametrics" } },
|
||||
{ "refId": "E", "expr": "unibus_store_kv", "legendFormat": "{{node}} · store-kv", "datasource": { "type": "prometheus", "uid": "victoriametrics" } }
|
||||
],
|
||||
"fieldConfig": { "defaults": { "custom": { "fillOpacity": 80, "lineWidth": 0 }, "mappings": [ { "type": "value", "options": { "0": { "text": "off", "color": "red" }, "1": { "text": "on", "color": "green" } } }, { "type": "special", "options": { "match": "null", "result": { "text": "no reporta", "color": "dark-red" } } } ], "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "green", "value": 1 } ] } }, "overrides": [] },
|
||||
"options": { "showValue": "auto", "alignValue": "center", "mergeValues": true, "rowHeight": 0.9, "legend": { "displayMode": "list", "placement": "bottom" } }
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"type": "timeseries",
|
||||
"title": "Latencia de scrape healthz por nodo",
|
||||
"gridPos": { "h": 7, "w": 12, "x": 0, "y": 11 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [ { "refId": "A", "expr": "unibus_scrape_duration_seconds", "legendFormat": "{{node}}", "datasource": { "type": "prometheus", "uid": "victoriametrics" } } ],
|
||||
"fieldConfig": { "defaults": { "unit": "s", "min": 0, "custom": { "drawStyle": "line", "fillOpacity": 10, "showPoints": "never", "lineWidth": 2 } }, "overrides": [] },
|
||||
"options": { "legend": { "displayMode": "table", "placement": "right", "calcs": ["lastNotNull", "max"] }, "tooltip": { "mode": "multi", "sort": "desc" } }
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"type": "table",
|
||||
"title": "Estado actual por nodo",
|
||||
"gridPos": { "h": 7, "w": 12, "x": 12, "y": 13 },
|
||||
"datasource": { "type": "prometheus", "uid": "victoriametrics" },
|
||||
"targets": [
|
||||
{ "refId": "up", "expr": "last_over_time(unibus_up[2m])", "format": "table", "instant": true, "datasource": { "type": "prometheus", "uid": "victoriametrics" } },
|
||||
{ "refId": "enforce", "expr": "last_over_time(unibus_posture_enforce[2m])", "format": "table", "instant": true, "datasource": { "type": "prometheus", "uid": "victoriametrics" } },
|
||||
{ "refId": "acl", "expr": "last_over_time(unibus_posture_acl[2m])", "format": "table", "instant": true, "datasource": { "type": "prometheus", "uid": "victoriametrics" } },
|
||||
{ "refId": "tls", "expr": "last_over_time(unibus_posture_tls[2m])", "format": "table", "instant": true, "datasource": { "type": "prometheus", "uid": "victoriametrics" } },
|
||||
{ "refId": "kv", "expr": "last_over_time(unibus_store_kv[2m])", "format": "table", "instant": true, "datasource": { "type": "prometheus", "uid": "victoriametrics" } }
|
||||
],
|
||||
"transformations": [
|
||||
{ "id": "joinByField", "options": { "byField": "node", "mode": "outer" } },
|
||||
{ "id": "organize", "options": { "excludeByName": { "Time": true, "Time 1": true, "Time 2": true, "Time 3": true, "Time 4": true, "Time 5": true, "instance": true, "instance 1": true, "instance 2": true, "instance 3": true, "instance 4": true, "instance 5": true, "__name__": true, "__name__ 1": true, "__name__ 2": true, "__name__ 3": true, "__name__ 4": true, "__name__ 5": true, "job": true, "job 1": true, "job 2": true, "job 3": true, "job 4": true, "job 5": true }, "renameByName": { "node": "Nodo", "Value #up": "up", "Value #enforce": "enforce", "Value #acl": "acl", "Value #tls": "tls", "Value #kv": "store-kv" } } }
|
||||
],
|
||||
"fieldConfig": { "defaults": { "custom": { "align": "center" }, "mappings": [ { "type": "value", "options": { "0": { "text": "✗", "color": "red" }, "1": { "text": "✓", "color": "green" } } } ] }, "overrides": [] },
|
||||
"options": { "showHeader": true }
|
||||
}
|
||||
]
|
||||
}
|
||||
+9
-6
@@ -1,9 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Despliega metrics_agent en un nodo remoto como servicio systemd.
|
||||
#
|
||||
# Uso: ./deploy_agent.sh <node_name> <ssh_host> [arch]
|
||||
# Uso: ./deploy_agent.sh <node_name> <ssh_host> <role> [arch]
|
||||
# node_name : valor de la label "instance" en Grafana (ej. homer)
|
||||
# ssh_host : alias SSH del nodo (debe existir en ~/.ssh/config)
|
||||
# role : label "role" para filtrar en Grafana (local | vps | movil)
|
||||
# arch : amd64 (default) | arm64
|
||||
#
|
||||
# Requisitos:
|
||||
@@ -14,9 +15,10 @@
|
||||
# - sudo -n (sin password) disponible en el nodo remoto.
|
||||
set -euo pipefail
|
||||
|
||||
NODE="${1:?uso: deploy_agent.sh <node> <ssh_host> [arch]}"
|
||||
HOST="${2:?uso: deploy_agent.sh <node> <ssh_host> [arch]}"
|
||||
ARCH="${3:-amd64}"
|
||||
NODE="${1:?uso: deploy_agent.sh <node> <ssh_host> <role> [arch]}"
|
||||
HOST="${2:?uso: deploy_agent.sh <node> <ssh_host> <role> [arch]}"
|
||||
ROLE="${3:?uso: deploy_agent.sh <node> <ssh_host> <role> [arch]}"
|
||||
ARCH="${4:-amd64}"
|
||||
|
||||
HUB="https://metrics-dxaqj3ina6eqd5pjt85wkrrj.organic-machine.com/api/v1/import/prometheus"
|
||||
LOKI="https://logs-wmaxecsjcfnocz81d5luca92.organic-machine.com/loki/api/v1/push"
|
||||
@@ -29,7 +31,7 @@ echo ">> copiando binario a $HOST"
|
||||
scp -q -o BatchMode=yes "$BIN" "$HOST:/tmp/metrics_agent"
|
||||
|
||||
echo ">> instalando servicio en $NODE ($HOST)"
|
||||
ssh -o BatchMode=yes "$HOST" "NODE='$NODE' PW='$PW' HUB='$HUB' LOKI='$LOKI' bash -s" <<'OUTER'
|
||||
ssh -o BatchMode=yes "$HOST" "NODE='$NODE' PW='$PW' HUB='$HUB' LOKI='$LOKI' ROLE='$ROLE' bash -s" <<'OUTER'
|
||||
set -e
|
||||
sudo -n mkdir -p /opt/fleet-agent /etc/fleet-agent
|
||||
sudo -n mv /tmp/metrics_agent /opt/fleet-agent/metrics_agent
|
||||
@@ -41,7 +43,8 @@ sudo -n tee /etc/fleet-agent/agent.json >/dev/null <<JSON
|
||||
"loki_url": "${LOKI}",
|
||||
"user": "fleet",
|
||||
"pass": "${PW}",
|
||||
"interval_sec": 15
|
||||
"interval_sec": 15,
|
||||
"labels": { "role": "${ROLE}" }
|
||||
}
|
||||
JSON
|
||||
sudo -n chmod 600 /etc/fleet-agent/agent.json
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
# `termux-services` y `termux-api`, y un alias SSH al sshd de Termux.
|
||||
set -euo pipefail
|
||||
|
||||
NODE="${1:?uso: deploy_agent_termux.sh <node> <ssh_alias>}"
|
||||
HOST="${2:?uso: deploy_agent_termux.sh <node> <ssh_alias>}"
|
||||
NODE="${1:?uso: deploy_agent_termux.sh <node> <ssh_alias> [role]}"
|
||||
HOST="${2:?uso: deploy_agent_termux.sh <node> <ssh_alias> [role]}"
|
||||
ROLE="${3:-movil}"
|
||||
|
||||
HUB="https://metrics-dxaqj3ina6eqd5pjt85wkrrj.organic-machine.com/api/v1/import/prometheus"
|
||||
LOKI="https://logs-wmaxecsjcfnocz81d5luca92.organic-machine.com/loki/api/v1/push"
|
||||
@@ -27,7 +28,7 @@ ssh -o BatchMode=yes "$HOST" 'mkdir -p ~/fleet-agent'
|
||||
scp -q -o BatchMode=yes "$BIN" "$HOST:fleet-agent/metrics_agent"
|
||||
|
||||
echo ">> instalando servicio Termux en $NODE ($HOST)"
|
||||
ssh -o BatchMode=yes "$HOST" "NODE='$NODE' PW='$PW' HUB='$HUB' LOKI='$LOKI' bash -s" <<'OUTER'
|
||||
ssh -o BatchMode=yes "$HOST" "NODE='$NODE' PW='$PW' HUB='$HUB' LOKI='$LOKI' ROLE='$ROLE' bash -s" <<'OUTER'
|
||||
set -e
|
||||
PREFIX=/data/data/com.termux/files/usr
|
||||
HM=/data/data/com.termux/files/home
|
||||
@@ -41,6 +42,7 @@ cat > "$HM/fleet-agent/agent.json" <<JSON
|
||||
"user": "fleet",
|
||||
"pass": "${PW}",
|
||||
"interval_sec": 15,
|
||||
"labels": { "role": "${ROLE}" },
|
||||
"battery_file": "$HM/fleet-agent/battery.json",
|
||||
"log_file": "$HM/fleet-agent/logcat.log"
|
||||
}
|
||||
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
# Despliega unibus_exporter en un nodo (por defecto magnus, el hub) como servicio
|
||||
# systemd. El exporter sondea el /healthz de los 3 nodos del cluster unibus por
|
||||
# IP pública y empuja métricas de estado/posture a la VictoriaMetrics local.
|
||||
#
|
||||
# Uso: ./deploy_unibus_exporter.sh [node_name] [ssh_host]
|
||||
# node_name : nombre lógico del host donde corre el exporter (default magnus)
|
||||
# ssh_host : alias SSH de ese host (default om)
|
||||
#
|
||||
# Requisitos:
|
||||
# - Go instalado localmente (compila el binario amd64).
|
||||
# - La CA del cluster unibus en projects/message_bus/apps/unibus/deploy/tls/ca.crt
|
||||
# (o cluster/out/<n>/ca.crt — son idénticas).
|
||||
# - sudo -n (sin password) en el host remoto.
|
||||
set -euo pipefail
|
||||
|
||||
NODE="${1:-magnus}"
|
||||
HOST="${2:-om}"
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)" # projects/fleet_monitoring
|
||||
APP="$ROOT/apps/unibus_exporter"
|
||||
CA="$ROOT/../message_bus/apps/unibus/deploy/tls/ca.crt"
|
||||
HUB="http://127.0.0.1:8428/api/v1/import/prometheus" # VM local en el hub (sin auth)
|
||||
|
||||
[ -f "$CA" ] || { echo "ERROR: falta la CA del cluster en $CA"; exit 1; }
|
||||
|
||||
echo ">> compilando unibus_exporter (linux/amd64)"
|
||||
mkdir -p "$APP/dist"
|
||||
( cd "$APP" && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/unibus_exporter_amd64 . )
|
||||
BIN="$APP/dist/unibus_exporter_amd64"
|
||||
|
||||
echo ">> subiendo binario + CA a $HOST"
|
||||
scp -q -o BatchMode=yes "$BIN" "$HOST:/tmp/unibus_exporter"
|
||||
scp -q -o BatchMode=yes "$CA" "$HOST:/tmp/unibus_ca.crt"
|
||||
|
||||
echo ">> instalando servicio en $NODE ($HOST)"
|
||||
ssh -o BatchMode=yes "$HOST" "NODE='$NODE' HUB='$HUB' bash -s" <<'OUTER'
|
||||
set -e
|
||||
sudo -n mkdir -p /opt/unibus-exporter /etc/unibus-exporter
|
||||
sudo -n mv /tmp/unibus_exporter /opt/unibus-exporter/unibus_exporter
|
||||
sudo -n chmod 755 /opt/unibus-exporter/unibus_exporter
|
||||
sudo -n mv /tmp/unibus_ca.crt /etc/unibus-exporter/ca.crt
|
||||
sudo -n chmod 644 /etc/unibus-exporter/ca.crt
|
||||
sudo -n tee /etc/unibus-exporter/unibus.json >/dev/null <<JSON
|
||||
{
|
||||
"nodes": [
|
||||
{ "name": "magnus", "url": "https://135.125.201.30:8470/healthz" },
|
||||
{ "name": "homer", "url": "https://141.94.69.66:8470/healthz" },
|
||||
{ "name": "datardos", "url": "https://51.91.100.142:8470/healthz" }
|
||||
],
|
||||
"ca_cert_path": "/etc/unibus-exporter/ca.crt",
|
||||
"hub_url": "${HUB}",
|
||||
"user": "",
|
||||
"pass": "",
|
||||
"interval_sec": 15,
|
||||
"timeout_sec": 8,
|
||||
"labels": { "job": "unibus_exporter" }
|
||||
}
|
||||
JSON
|
||||
sudo -n chmod 600 /etc/unibus-exporter/unibus.json
|
||||
sudo -n tee /etc/systemd/system/unibus-exporter.service >/dev/null <<'UNIT'
|
||||
[Unit]
|
||||
Description=unibus cluster exporter (fleet_monitoring)
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/opt/unibus-exporter/unibus_exporter -config /etc/unibus-exporter/unibus.json
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
NoNewPrivileges=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
UNIT
|
||||
sudo -n systemctl daemon-reload
|
||||
sudo -n systemctl enable unibus-exporter >/dev/null 2>&1
|
||||
sudo -n systemctl restart unibus-exporter
|
||||
sleep 3
|
||||
echo -n "status: "; systemctl is-active unibus-exporter
|
||||
OUTER
|
||||
|
||||
echo ">> $NODE: unibus_exporter desplegado"
|
||||
Reference in New Issue
Block a user