mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
b2294d1cf1
add progress bars to the VM importer The new progress bars supposed to display the processing speed per each VM importer worker. This info should help to identify if there is a bottleneck on the VM side during the import process, without waiting for its finish. The new progress bars can be disabled by passing `vm-disable-progress-bar` flag. Plotting multiple progress bars requires using experimental progress bar pool from github.com/cheggaaa/pb/v3. Switch to progress bar pool required changes in all import modes. The openTSDB mode wasn't changed due to its implementation, which implies individual progress bars per each series. Because of this, using the pool wasn't possible. Signed-off-by: dmitryk-dk <kozlovdmitriyy@gmail.com> Co-authored-by: hagen1778 <roman@victoriametrics.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmctl/vm"
|
|
)
|
|
|
|
const barTpl = `{{ blue "%s:" }} {{ counters . }} {{ bar . "[" "█" (cycle . "█") "▒" "]" }} {{ percent . }}`
|
|
|
|
func prompt(question string) bool {
|
|
reader := bufio.NewReader(os.Stdin)
|
|
fmt.Print(question, " [Y/n] ")
|
|
answer, err := reader.ReadString('\n')
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
answer = strings.TrimSpace(strings.ToLower(answer))
|
|
if answer == "" || answer == "yes" || answer == "y" {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func wrapErr(vmErr *vm.ImportError, verbose bool) error {
|
|
var errTS string
|
|
var maxTS, minTS int64
|
|
for _, ts := range vmErr.Batch {
|
|
if minTS < ts.Timestamps[0] || minTS == 0 {
|
|
minTS = ts.Timestamps[0]
|
|
}
|
|
if maxTS < ts.Timestamps[len(ts.Timestamps)-1] {
|
|
maxTS = ts.Timestamps[len(ts.Timestamps)-1]
|
|
}
|
|
if verbose {
|
|
errTS += fmt.Sprintf("%s for timestamps range %d - %d\n",
|
|
ts.String(), ts.Timestamps[0], ts.Timestamps[len(ts.Timestamps)-1])
|
|
}
|
|
}
|
|
var verboseMsg string
|
|
if !verbose {
|
|
verboseMsg = "(enable `--verbose` output to get more details)"
|
|
}
|
|
if vmErr.Err == nil {
|
|
return fmt.Errorf("%s\n\tLatest delivered batch for timestamps range %d - %d %s\n%s",
|
|
vmErr.Err, minTS, maxTS, verboseMsg, errTS)
|
|
}
|
|
return fmt.Errorf("%s\n\tImporting batch failed for timestamps range %d - %d %s\n%s",
|
|
vmErr.Err, minTS, maxTS, verboseMsg, errTS)
|
|
}
|