Skip to content

Commit ed91653

Browse files
committed
Add --avalanche-flags to try to match the input metrics
The --avalanche-flags-for-adjusted-series option requires you to input the total number of series to target. So it's not convenient to run mtypes once on a workload to say "just try to approximate its output for me". The new --avalanche-flags will do just that, by using the computed series total as the input for the adjusted series target.
1 parent bf248f6 commit ed91653

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cmd/mtypes/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ var metricType_NATIVE_HISTOGRAM dto.MetricType = 999 //nolint:revive
4444

4545
func main() {
4646
resource := flag.String("resource", "", "Path or URL to the resource (file, <url>/metrics) containing Prometheus metric format.")
47-
avalancheFlagsForTotal := flag.Int("avalanche-flags-for-adjusted-series", 0, "If more than zero, it additionally prints flags for the avalanche 0.6.0 command line to generate metrics for the similar type distribution; to get the total number of adjusted series to the given value.")
47+
avalancheFlags := flag.Bool("avalanche-flags", false, "If passed, prints flags for avalanche to generate metrics to approximate the metrics count and type distribution from the input.")
48+
avalancheFlagsForTotal := flag.Int("avalanche-flags-for-adjusted-series", 0, "If more than zero, adjust the printed avalanche flags to scale the total number of adjusted series to the given value.")
4849
flag.Parse()
4950

51+
if *avalancheFlagsForTotal > 0 {
52+
// --avalanche-flags-for-adjusted-series implies --avalanche-flags
53+
*avalancheFlags = true
54+
}
55+
5056
var input io.Reader = os.Stdin
5157
if *resource != "" {
5258
switch {
@@ -76,6 +82,9 @@ func main() {
7682
}
7783
total := computeTotal(statistics)
7884
writeStatistics(os.Stdout, total, statistics)
85+
if *avalancheFlags && *avalancheFlagsForTotal <= 0 {
86+
*avalancheFlagsForTotal = total.series
87+
}
7988
if *avalancheFlagsForTotal > 0 {
8089
fmt.Fprintln(os.Stdout)
8190
fmt.Fprintln(os.Stdout, "Avalanche flags for the similar distribution to get to the adjusted series goal of:", *avalancheFlagsForTotal)

0 commit comments

Comments
 (0)