From 32a6b67e6c349e741a422f86b9a7cecec523d9c8 Mon Sep 17 00:00:00 2001 From: Dmytro Kozlov Date: Mon, 2 May 2022 11:08:24 +0300 Subject: [PATCH] vmalert: added disableProgressBar flag which disable progressbar (#2506) vmalert: added disableProgressBar flag which disable progressbar https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1761 --- app/vmalert/README.md | 3 +++ app/vmalert/replay.go | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/vmalert/README.md b/app/vmalert/README.md index 556bdd847..50ffe39b3 100644 --- a/app/vmalert/README.md +++ b/app/vmalert/README.md @@ -481,6 +481,9 @@ per rule before giving up. (rules which depend on each other) rules. It is expected, that remote storage will be able to persist previously accepted data during the delay, so data will be available for the subsequent queries. Keep it equal or bigger than `-remoteWrite.flushInterval`. +* `replay.disableProgressBar` - whether to disable progress bar which shows progress work. +Progress bar may generate a lot of log records, which is not formatted as standard VictoriaMetrics logger. +It could break logs parsing by external system and generate additional load on it. See full description for these flags in `./vmalert --help`. diff --git a/app/vmalert/replay.go b/app/vmalert/replay.go index f702f11d3..c02112241 100644 --- a/app/vmalert/replay.go +++ b/app/vmalert/replay.go @@ -29,6 +29,8 @@ var ( "Max number of data points expected in one request. The higher the value, the less requests will be made during replay.") replayRuleRetryAttempts = flag.Int("replay.ruleRetryAttempts", 5, "Defines how many retries to make before giving up on rule if request for it returns an error.") + disableProgressBar = flag.Bool("replay.disableProgressBar", false, "Whether to disable rendering progress bars during the replay. "+ + "Progress bar rendering might be verbose or break the logs parsing, so it is recommended to be disabled when not used in interactive mode.") ) func replay(groupsCfg []config.Group, qb datasource.QuerierBuilder, rw *remotewrite.Client) error { @@ -88,7 +90,10 @@ func (g *Group) replay(start, end time.Time, rw *remotewrite.Client) int { g.Name, g.Interval, iterations, step) for _, rule := range g.Rules { fmt.Printf("> Rule %q (ID: %d)\n", rule, rule.ID()) - bar := pb.StartNew(iterations) + var bar *pb.ProgressBar + if !*disableProgressBar { + bar = pb.StartNew(iterations) + } ri.reset() for ri.next() { n, err := replayRule(rule, ri.s, ri.e, rw) @@ -96,9 +101,13 @@ func (g *Group) replay(start, end time.Time, rw *remotewrite.Client) int { logger.Fatalf("rule %q: %s", rule, err) } total += n - bar.Increment() + if bar != nil { + bar.Increment() + } + } + if bar != nil { + bar.Finish() } - bar.Finish() // sleep to let remote storage to flush data on-disk // so chained rules could be calculated correctly time.Sleep(*replayRulesDelay)