Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metrics: export meta backup metrics #4480

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ func initBackgroundTasks(c *cli.Context, vfsConf *vfs.Config, metaConf *meta.Con
vfsConf.Port.ConsulAddr = c.String("consul")
}
if !metaConf.ReadOnly && !metaConf.NoBGJob && vfsConf.BackupMeta > 0 {
registerer.MustRegister(vfs.LastBackupTimeG)
registerer.MustRegister(vfs.LastBackupDurationG)
go vfs.Backup(m, blob, vfsConf.BackupMeta)
}
if !c.Bool("no-usage-report") {
Expand Down
14 changes: 14 additions & 0 deletions pkg/vfs/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ import (
"github.com/juicedata/juicefs/pkg/object"
osync "github.com/juicedata/juicefs/pkg/sync"
"github.com/juicedata/juicefs/pkg/utils"
"github.com/prometheus/client_golang/prometheus"
)

var (
LastBackupTimeG = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "last_successful_backup",
Help: "Last successful backup.",
})
LastBackupDurationG = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "last_backup_duration",
Help: "Last backup duration.",
})
)

// Backup metadata periodically in the object storage
Expand Down Expand Up @@ -66,10 +78,12 @@ func Backup(m meta.Meta, blob object.ObjectStorage, interval time.Duration) {
go cleanupBackups(blob, now)
logger.Debugf("backup metadata started")
if err = backup(m, blob, now); err == nil {
LastBackupTimeG.Set(float64(now.UnixNano()) / 1e9)
logger.Infof("backup metadata succeed, used %s", time.Since(now))
} else {
logger.Warnf("backup metadata failed: %s", err)
}
LastBackupDurationG.Set(time.Since(now).Seconds())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a label to indicate success/failure?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can know that when last_sucessfull_backup is not updated.

}
}
}
Expand Down
Loading