Files
home_automatization/monitoring/grafana/provisioning/dashboards/automation-devices.json
T
cacto 17af76c159 Вынос health-check-service в отдельный сервис
Тикер офлайн-детекции (internal/healthcheck) переехал из
device-control-service в новый самостоятельный Go-сервис — как и
планировалось с самого начала (см. изначальный README-заглушку).
Детекция online остаётся в device-control-service: она происходит
как побочный эффект уже имеющейся там MQTT-подписки на
devices/+/telemetry и devices/+/ack, заводить для этого отдельный
сервис с дублирующей MQTT-подпиской избыточно.

health-check-service — свой Go-модуль (без зависимости от proto/,
сборка из собственного контекста), читает только узкое
read+offline-подмножество Device Shadow keyspace в Redis
(devices:known, status, last_seen) — полный Shadow API с записью
desired/reported state остаётся только в device-control-service.

Метрика device_control_health_transitions_total переименована в
device_health_transitions_total и теперь публикуется с этим именем
из ДВУХ сервисов (device-control-service — direction=online,
health-check-service — direction=offline): Prometheus агрегирует
одноимённые метрики с разных таргетов прозрачно, поэтому Grafana-
дашборд адаптирован простой сменой имени метрики в запросе, без
переделки панели.

Проверено вживую через docker compose: реальный online→offline
переход (публикация тестовой телеметрии + ожидание таймаута)
корректно долетает до Redis и RabbitMQ (device.status_changed),
Prometheus видит новый scrape-таргет как up.
2026-08-13 11:24:25 +05:00

84 lines
2.5 KiB
JSON

{
"uid": "automation-devices",
"title": "Automation & Devices",
"tags": ["home-automation"],
"timezone": "browser",
"schemaVersion": 39,
"version": 1,
"refresh": "10s",
"time": { "from": "now-30m", "to": "now" },
"panels": [
{
"id": 1,
"title": "Rules triggered (rate, by outcome)",
"type": "timeseries",
"datasource": { "type": "prometheus", "uid": "Prometheus" },
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
"targets": [
{
"expr": "sum by (outcome) (rate(rule_engine_rules_triggered_total[1m]))",
"legendFormat": "{{outcome}}",
"refId": "A"
}
]
},
{
"id": 2,
"title": "device-control-service dispatch duration (p95, by action)",
"type": "timeseries",
"datasource": { "type": "prometheus", "uid": "Prometheus" },
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
"fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] },
"targets": [
{
"expr": "histogram_quantile(0.95, sum(rate(rule_engine_dispatch_duration_seconds_bucket[5m])) by (le, action_type))",
"legendFormat": "{{action_type}}",
"refId": "A"
}
]
},
{
"id": 3,
"title": "Device commands (rate, by action + outcome)",
"type": "timeseries",
"datasource": { "type": "prometheus", "uid": "Prometheus" },
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 8 },
"targets": [
{
"expr": "sum by (action, outcome) (rate(device_control_commands_total[1m]))",
"legendFormat": "{{action}} / {{outcome}}",
"refId": "A"
}
]
},
{
"id": 4,
"title": "Device online/offline transitions (rate)",
"type": "timeseries",
"datasource": { "type": "prometheus", "uid": "Prometheus" },
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 8 },
"targets": [
{
"expr": "sum by (direction) (rate(device_health_transitions_total[5m]))",
"legendFormat": "{{direction}}",
"refId": "A"
}
]
},
{
"id": 5,
"title": "Automation rule cache refreshes (rate, by outcome)",
"type": "timeseries",
"datasource": { "type": "prometheus", "uid": "Prometheus" },
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 16 },
"targets": [
{
"expr": "sum by (outcome) (rate(rule_engine_cache_refresh_total[1m]))",
"legendFormat": "{{outcome}}",
"refId": "A"
}
]
}
]
}