add new metrics (gauges): backup_total and restore_total

Signed-off-by: fabito <fuechi@ciandt.com>
This commit is contained in:
fabito
2019-04-04 23:11:53 -03:00
parent f8f0d15da2
commit 475cf2ab60
4 changed files with 54 additions and 0 deletions

View File

@@ -111,6 +111,8 @@ func NewBackupController(
backupLocationInformer.Informer().HasSynced,
volumeSnapshotLocationInformer.Informer().HasSynced,
)
c.resyncFunc = c.resync
c.resyncPeriod = time.Minute
backupInformer.Informer().AddEventHandler(
cache.ResourceEventHandlerFuncs{
@@ -141,6 +143,15 @@ func NewBackupController(
return c
}
func (c *backupController) resync() {
backups, err := c.lister.List(labels.Everything())
if err != nil {
c.logger.Error(err, "Error computing backup_total metric")
} else {
c.metrics.SetBackupTotal(int64(len(backups)))
}
}
func (c *backupController) processBackup(key string) error {
log := c.logger.WithField("key", key)