Добавлены метрики 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:
@@ -10,6 +10,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.cactoz.su/cacto/home_automatization/services/rule-engine-service/internal/metrics"
|
||||
"git.cactoz.su/cacto/home_automatization/services/rule-engine-service/internal/rules"
|
||||
)
|
||||
|
||||
@@ -88,12 +89,14 @@ func (c *Cache) loop() {
|
||||
func (c *Cache) refresh(ctx context.Context) error {
|
||||
dbRows, err := c.fetcher.FetchActiveRules(ctx)
|
||||
if err != nil {
|
||||
metrics.CacheRefreshes.WithLabelValues("error").Inc()
|
||||
return err
|
||||
}
|
||||
index := buildIndex(dbRows, c.logger)
|
||||
c.mu.Lock()
|
||||
c.index = index
|
||||
c.mu.Unlock()
|
||||
metrics.CacheRefreshes.WithLabelValues("success").Inc()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user