mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-30 02:02:48 +00:00
* prometheus/alertmanager#2372 Move config reload metrics to Coordinator.Reload() Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com> * #2372 Minor refactoring. Signed-off-by: Kevin Hellemun <17928966+OGKevin@users.noreply.github.com>
This commit is contained in:
parent
59a96579cc
commit
dd1a8fb77b
@ -17,7 +17,6 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/go-kit/kit/log/level"
|
||||
@ -97,15 +96,10 @@ func (c *Coordinator) notifySubscribers() error {
|
||||
func (c *Coordinator) loadFromFile() error {
|
||||
conf, err := LoadFile(c.configFilePath)
|
||||
if err != nil {
|
||||
c.configSuccessMetric.Set(0)
|
||||
return err
|
||||
}
|
||||
|
||||
c.config = conf
|
||||
c.configSuccessMetric.Set(1)
|
||||
c.configSuccessTimeMetric.Set(float64(time.Now().Unix()))
|
||||
hash := md5HashAsMetricValue([]byte(c.config.original))
|
||||
c.configHashMetric.Set(hash)
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -126,6 +120,7 @@ func (c *Coordinator) Reload() error {
|
||||
"file", c.configFilePath,
|
||||
"err", err,
|
||||
)
|
||||
c.configSuccessMetric.Set(0)
|
||||
return err
|
||||
}
|
||||
level.Info(c.logger).Log(
|
||||
@ -139,9 +134,15 @@ func (c *Coordinator) Reload() error {
|
||||
"file", c.configFilePath,
|
||||
"err", err,
|
||||
)
|
||||
c.configSuccessMetric.Set(0)
|
||||
return err
|
||||
}
|
||||
|
||||
c.configSuccessMetric.Set(1)
|
||||
c.configSuccessTimeMetric.SetToCurrentTime()
|
||||
hash := md5HashAsMetricValue([]byte(c.config.original))
|
||||
c.configHashMetric.Set(hash)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user