Добавлены метрики 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,37 @@
|
||||
// Package metrics defines rule-engine-service's Prometheus metrics.
|
||||
// Registered automatically (via promauto) into the default registry on
|
||||
// import; served by main.go's dedicated metrics HTTP server.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
var (
|
||||
ReadingsConsumed = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "rule_engine_readings_consumed_total",
|
||||
Help: "Total number of telemetry.new_reading events consumed from RabbitMQ.",
|
||||
})
|
||||
|
||||
RulesMatched = promauto.NewCounter(prometheus.CounterOpts{
|
||||
Name: "rule_engine_rules_matched_total",
|
||||
Help: "Total number of rule conditions that evaluated true and were dispatched.",
|
||||
})
|
||||
|
||||
RulesTriggered = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "rule_engine_rules_triggered_total",
|
||||
Help: "Total number of rule dispatch attempts, by action type and outcome.",
|
||||
}, []string{"action_type", "outcome"})
|
||||
|
||||
DispatchDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Name: "rule_engine_dispatch_duration_seconds",
|
||||
Help: "Duration of the gRPC/HTTP call to device-control-service, by action type.",
|
||||
Buckets: prometheus.DefBuckets,
|
||||
}, []string{"action_type"})
|
||||
|
||||
CacheRefreshes = promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "rule_engine_cache_refresh_total",
|
||||
Help: "Total number of automation_rules cache refreshes from PostgreSQL, by outcome.",
|
||||
}, []string{"outcome"})
|
||||
)
|
||||
Reference in New Issue
Block a user