From 1cc06e39cd74a916bb166bfaff6bc0bfc80d6a15 Mon Sep 17 00:00:00 2001 From: Alexander Marshalov <_@marshalov.org> Date: Wed, 28 Jun 2023 14:44:45 +0200 Subject: [PATCH] show backup progress percentage in vmbackup log during backup uploading and restoring progress percentage in vmrestore log during backup downloading (#4460) (#4530) Signed-off-by: Alexander Marshalov <_@marshalov.org> --- docs/CHANGELOG.md | 2 ++ lib/backup/actions/backup.go | 3 ++- lib/backup/actions/restore.go | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 91b5daa46..ae5045ce4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -36,6 +36,8 @@ The following tip changes can be tested by building VictoriaMetrics components f * FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): update retry policy for pushing data to `-remoteWrite.url`. By default, vmalert will make multiple retry attempts with exponential delay. The total time spent during retry attempts shouldn't exceed `-remoteWrite.retryMaxTime` (default is 30s). When retry time is exceeded vmalert drops the data dedicated for `-remoteWrite.url`. Before, vmalert dropped data after 5 retry attempts with 1s delay between attempts (not configurable). See `-remoteWrite.retryMinInterval` and `-remoteWrite.retryMaxTime` cmd-line flags. * FEATURE: [vmalert](https://docs.victoriametrics.com/vmalert.html): expose `vmalert_remotewrite_send_duration_seconds_total` counter, which can be used for determining high saturation of every connection to remote storage with an alerting query `sum(rate(vmalert_remotewrite_send_duration_seconds_total[5m])) by(job, instance) > 0.9 * max(vmalert_remotewrite_concurrency) by(job, instance)`. This query triggers when a connection is saturated by more than 90%. This usually means that `-remoteWrite.concurrency` command-line flag must be increased in order to increase the number of concurrent writings into remote endpoint. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4516). * FEATURE: [vmauth](https://docs.victoriametrics.com/vmauth.html): expose `vmauth_user_request_duration_seconds` and `vmauth_unauthorized_user_request_duration_seconds` summary metrics for measuring requests latency per user. +* FEATURE: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): show backup progress percentage in log during backup uploading. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4460). +* FEATURE: [vmrestore](https://docs.victoriametrics.com/vmrestore.html): show restoring progress percentage in log during backup downloading. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4460). * BUGFIX: add the following command-line flags, which can be used for limiting Graphite API calls: `--search.maxGraphiteTagKeys` for limiting the number of tag keys returned from Graphite `/tags`, `/tags/autoComplete/*`, `/tags/findSeries` API. diff --git a/lib/backup/actions/backup.go b/lib/backup/actions/backup.go index 108cd3630..31bf9188b 100644 --- a/lib/backup/actions/backup.go +++ b/lib/backup/actions/backup.go @@ -205,7 +205,8 @@ func runBackup(src *fslocal.FS, dst common.RemoteFS, origin common.OriginFS, con return nil }, func(elapsed time.Duration) { n := atomic.LoadUint64(&bytesUploaded) - logger.Infof("uploaded %d out of %d bytes from src %s to dst %s in %s", n, uploadSize, src, dst, elapsed) + prc := 100 * float64(n) / float64(uploadSize) + logger.Infof("uploaded %d out of %d bytes (%.2f%%) from src %s to dst %s in %s", n, uploadSize, prc, src, dst, elapsed) }) atomic.AddUint64(&bytesUploadedTotal, bytesUploaded) bytesUploadedTotalMetric.Set(bytesUploadedTotal) diff --git a/lib/backup/actions/restore.go b/lib/backup/actions/restore.go index 2d81bf3d2..62cf89c03 100644 --- a/lib/backup/actions/restore.go +++ b/lib/backup/actions/restore.go @@ -180,7 +180,8 @@ func (r *Restore) Run() error { return nil }, func(elapsed time.Duration) { n := atomic.LoadUint64(&bytesDownloaded) - logger.Infof("downloaded %d out of %d bytes from %s to %s in %s", n, downloadSize, src, dst, elapsed) + prc := 100 * float64(n) / float64(downloadSize) + logger.Infof("downloaded %d out of %d bytes (%.2f%%) from %s to %s in %s", n, downloadSize, prc, src, dst, elapsed) }) if err != nil { return err