Добавлены метрики Prometheus и дашборды Grafana (этап 2.5)
Все три Go-сервиса (ingest, device-control, rule-engine) отдают /metrics в формате Prometheus: счётчики MQTT/RabbitMQ/ClickHouse операций, гистограммы длительности батч-флашей и диспатча правил, переходы устройств online/offline. Добавлены сервисы prometheus и grafana в docker-compose с провижининг конфигом (datasource + два готовых дашборда: "Ingest & Telemetry" и "Automation & Devices").
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Package metrics defines device-control-service's Prometheus metrics.
|
||||
// Registered automatically (via promauto) into the default registry on
|
||||
// import; served alongside the command HTTP API's /metrics route.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
var (
|
||||
CommandsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "device_control_commands_total",
|
||||
Help: "Total number of TurnOn/TurnOff/SetLevel commands dispatched, by action and outcome.",
|
||||
}, []string{"action", "outcome"})
|
||||
|
||||
CommandDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Name: "device_control_command_duration_seconds",
|
||||
Help: "Duration of a command dispatch (Redis desired_state patch + MQTT publish), by action.",
|
||||
Buckets: prometheus.DefBuckets,
|
||||
}, []string{"action"})
|
||||
|
||||
MQTTEventsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "device_control_mqtt_events_total",
|
||||
Help: "Total number of telemetry/ack messages received, by event type and outcome.",
|
||||
}, []string{"event_type", "outcome"})
|
||||
|
||||
HealthTransitionsTotal = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "device_control_health_transitions_total",
|
||||
Help: "Total number of device online/offline transitions detected.",
|
||||
}, []string{"direction"})
|
||||
)
|
||||
Reference in New Issue
Block a user