From d9933d09250420b1ed3c3cdff0d3dfd1f7ddd0ea Mon Sep 17 00:00:00 2001 From: marco Date: Thu, 15 Feb 2024 09:19:08 +0100 Subject: [PATCH] cscli metrics: rename buckets -> scenarios --- cmd/crowdsec-cli/metrics.go | 10 +++++----- cmd/crowdsec-cli/metrics_table.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/crowdsec-cli/metrics.go b/cmd/crowdsec-cli/metrics.go index 6e23bcf12e4..485a341a6aa 100644 --- a/cmd/crowdsec-cli/metrics.go +++ b/cmd/crowdsec-cli/metrics.go @@ -59,7 +59,7 @@ type metricStore map[string]metricSection func NewMetricStore() metricStore { return metricStore{ "acquisition": statAcquis{}, - "buckets": statBucket{}, + "scenarios": statBucket{}, "parsers": statParser{}, "lapi": statLapi{}, "lapi-machine": statLapiMachine{}, @@ -110,7 +110,7 @@ func (ms metricStore) Fetch(url string) error { mAcquis := ms["acquisition"].(statAcquis) mParser := ms["parsers"].(statParser) - mBucket := ms["buckets"].(statBucket) + mBucket := ms["scenarios"].(statBucket) mLapi := ms["lapi"].(statLapi) mLapiMachine := ms["lapi-machine"].(statLapiMachine) mLapiBouncer := ms["lapi-bouncer"].(statLapiBouncer) @@ -383,7 +383,7 @@ func (cli *cliMetrics) expandSectionGroups(args []string) []string { for _, section := range args { switch section { case "engine": - ret = append(ret, "acquisition", "parsers", "buckets", "stash", "whitelists") + ret = append(ret, "acquisition", "parsers", "scenarios", "stash", "whitelists") case "lapi": ret = append(ret, "alerts", "decisions", "lapi", "lapi-bouncer", "lapi-decisions", "lapi-machine") case "appsec": @@ -413,10 +413,10 @@ cscli metrics show cscli metrics show engine # Show some specific metrics, show empty tables, connect to a different url -cscli metrics show acquisition parsers buckets stash --url http://lapi.local:6060/metrics +cscli metrics show acquisition parsers scenarios stash --url http://lapi.local:6060/metrics # Show metrics in json format -cscli metrics show acquisition parsers buckets stash -o json`, +cscli metrics show acquisition parsers scenarios stash -o json`, // Positional args are optional DisableAutoGenTag: true, RunE: func(_ *cobra.Command, args []string) error { diff --git a/cmd/crowdsec-cli/metrics_table.go b/cmd/crowdsec-cli/metrics_table.go index da6ea3d9f1d..7e05224ccd3 100644 --- a/cmd/crowdsec-cli/metrics_table.go +++ b/cmd/crowdsec-cli/metrics_table.go @@ -127,7 +127,7 @@ func metricsToTable(t *table.Table, stats map[string]map[string]int, keys []stri } func (s statBucket) Description() (string, string) { - return "Bucket Metrics", + return "Scenario Metrics", `Measure events in different scenarios. Current count is the number of buckets during metrics collection. ` + `Overflows are past event-producing buckets, while Expired are the ones that didn’t receive enough events to Overflow.` } @@ -143,13 +143,13 @@ func (s statBucket) Process(bucket, metric string, val int) { func (s statBucket) Table(out io.Writer, noUnit bool, showEmpty bool) { t := newTable(out) t.SetRowLines(false) - t.SetHeaders("Bucket", "Current Count", "Overflows", "Instantiated", "Poured", "Expired") + t.SetHeaders("Scenario", "Current Count", "Overflows", "Instantiated", "Poured", "Expired") t.SetAlignment(table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft, table.AlignLeft) keys := []string{"curr_count", "overflow", "instantiation", "pour", "underflow"} if numRows, err := metricsToTable(t, s, keys, noUnit); err != nil { - log.Warningf("while collecting bucket stats: %s", err) + log.Warningf("while collecting scenario stats: %s", err) } else if numRows > 0 || showEmpty { title, _ := s.Description() renderTableTitle(out, "\n"+title+":")