Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lapi detailed metrics #2858

Merged
merged 145 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
d1f6226
add /usage-metrics endpoint definition
blotus Feb 2, 2024
76c04fd
regenerate pkg/models
mmetc Feb 8, 2024
c325c27
(wip) lp metrics
mmetc Mar 12, 2024
d9a3819
ignore duplicate data points
mmetc Mar 8, 2024
876c339
lint
mmetc Mar 8, 2024
b00e553
interval messages
mmetc Mar 11, 2024
95f38d9
explicit message for 404
mmetc Mar 11, 2024
11499c8
display more LP information in cscli
blotus Mar 21, 2024
dbdf3ad
wip
blotus Mar 21, 2024
33778ca
wip
blotus Mar 22, 2024
0be7cc3
store more payload
blotus Apr 19, 2024
be64f61
set pushed_at after sending metrics
blotus Apr 19, 2024
2b940a4
up
blotus Apr 22, 2024
c6ebd7a
handle 422 error from CAPI
blotus Apr 22, 2024
f085318
update swagger and models
blotus Apr 22, 2024
7b093b9
add lapi metrics in swagger and models
blotus Apr 22, 2024
18b8ddb
add missing file
blotus Apr 22, 2024
538ab0b
up
blotus Apr 22, 2024
3169343
Merge branch 'master' into lapi-detailed-metrics
blotus Apr 22, 2024
e36d2cb
up
blotus Apr 22, 2024
12ce5e3
add more required fields in models
blotus Apr 23, 2024
675a7ee
merge master
blotus May 2, 2024
31e68cf
merge master
blotus May 2, 2024
8d62aef
fix test
blotus May 2, 2024
de26714
add cscli machines inspect
blotus May 2, 2024
f6b8b01
lint
blotus May 3, 2024
9d6b6cd
fix bats test for usage-metrics
blotus May 3, 2024
088dd1a
lint
blotus May 3, 2024
0a247c1
merge master branch
blotus Jun 6, 2024
f08a6bc
remove console_options for LPs
blotus Jun 6, 2024
0cd822a
wip
blotus Jun 11, 2024
5c8cfad
wip
blotus Jun 18, 2024
61d2dba
wip
blotus Jun 18, 2024
2fd72e7
up
blotus Jun 19, 2024
16c7d59
up
blotus Jun 20, 2024
0bfbd3e
up
blotus Jun 25, 2024
df43eaf
up
blotus Jun 25, 2024
727b2e3
remove feature flag
blotus Jun 25, 2024
1cb5675
mark metrics as sent on 422
blotus Jun 26, 2024
95b1082
always send datasources
blotus Jun 26, 2024
e5d1485
Merge branch 'master' into lapi-detailed-metrics
mmetc Jun 28, 2024
4ab5a53
update functional test; workaround for openapi verbose error
mmetc Jun 28, 2024
ea70f25
redundant import alias
mmetc Jun 28, 2024
518cd86
split metrics func tests to own file
mmetc Jun 28, 2024
2cb7bbb
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 1, 2024
be4dc1d
wip machines and hub state
mmetc Jul 1, 2024
f7978c7
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 1, 2024
141ae11
wip
mmetc Jul 2, 2024
dae1cc6
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 2, 2024
76ed1e5
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 2, 2024
e18791a
update for hub state change
mmetc Jul 2, 2024
b1dd9fd
inspect -o json
mmetc Jul 3, 2024
a470989
validate metrics body based on auth type
blotus Jul 3, 2024
4e2a3f5
machines list -o raw: show timestamp instead of delta for last_heartbeat
mmetc Jul 3, 2024
18cc51d
merge back bouncers_table.go to list command
mmetc Jul 3, 2024
0f1e38a
func test empty payload
mmetc Jul 3, 2024
5298236
cscli bouncers inspect
mmetc Jul 3, 2024
06ff891
bouncer feature flags; handle lastpull == nil
mmetc Jul 3, 2024
450387e
feature flags
mmetc Jul 3, 2024
3ba3236
disable redundant-import-alias linter
mmetc Jul 3, 2024
421ceb2
order items by name before sending metrics
mmetc Jul 3, 2024
d447943
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 3, 2024
af0ef90
basic tests
blotus Jul 3, 2024
8e4ad91
up
blotus Jul 3, 2024
af278ce
up
blotus Jul 4, 2024
9fb1d40
up
blotus Jul 4, 2024
7431b52
up
blotus Jul 4, 2024
636ce5c
dry
mmetc Jul 4, 2024
a887d40
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 4, 2024
198fc6c
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 4, 2024
d3e6560
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 4, 2024
b577647
send metrics every 30 minutes to CAPI
blotus Jul 5, 2024
66ad913
sort type names
mmetc Jul 4, 2024
90e60ec
explicit soft wrap
mmetc Jul 5, 2024
7f923b0
extract method processMetrics()
mmetc Jul 5, 2024
e55f3a8
statbouncer.go
mmetc Jul 5, 2024
8759e4f
reduce verbositiy, format byte totals, warn only once per each error
mmetc Jul 9, 2024
36e34a4
todo
mmetc Jul 9, 2024
8657560
cscli metrics: drop support for '-o raw' (just use json)
mmetc Jul 9, 2024
42c1439
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 9, 2024
df5ba9f
wip bytes/packets
mmetc Jul 9, 2024
7665c7a
update func tests
mmetc Jul 10, 2024
6670b08
fup
mmetc Jul 10, 2024
3b08f82
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 10, 2024
1cac76a
more readable tests
mmetc Jul 10, 2024
6df2462
more bouncer tests
mmetc Jul 10, 2024
4577568
test data
mmetc Jul 10, 2024
70f9c65
stable row order
mmetc Jul 10, 2024
f525003
rename package to avoid shadowing
mmetc Jul 11, 2024
2236994
remove metric payload size limit
mmetc Jul 11, 2024
3519bf4
update log/error messages; lint
mmetc Jul 11, 2024
0467486
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 11, 2024
0a74de5
footer with totals by origin; fix display of 0 values
mmetc Jul 11, 2024
50c772a
add maxLength for some elements
blotus Jul 11, 2024
69f7a4e
revert "db: round created, updated... timestamps to 1 second" to fix …
mmetc Jul 11, 2024
8c73c1a
table formatting
mmetc Jul 11, 2024
daf7a13
bouncer stats: dynamic columns
mmetc Jul 12, 2024
9af0055
removed temporary hack
mmetc Jul 12, 2024
987f155
fix multiple bouncer tables
mmetc Jul 12, 2024
2f97c3b
extract method bouncerTable(), separate tables with newline
mmetc Jul 12, 2024
adc86c2
continue loop if metric row can't be parsed
mmetc Jul 12, 2024
2d7b8e7
show earliest collection date for each bouncer
mmetc Jul 12, 2024
11bba5e
func tests: add back sleep for mysql
mmetc Jul 12, 2024
e4cbed1
detect os when in docker, report ex. osname = "Debian (docker)"
mmetc Jul 12, 2024
3365371
describe CAPI as CAPI (community blocklist) in table output only (not…
mmetc Jul 12, 2024
5e07560
display metrics without origin only in the total line
mmetc Jul 12, 2024
8e4622f
display "-" for missing data (like per-origin processed bytes/packets)
mmetc Jul 12, 2024
e8dd87a
pluralize known unit names
mmetc Jul 12, 2024
d671a67
enable 08_* func tests
mmetc Jul 15, 2024
facc26d
comments
mmetc Jul 15, 2024
0381678
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 15, 2024
308b29b
use version.DetectOS() from go-cs-lib
mmetc Jul 15, 2024
3bbed0d
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 15, 2024
1f8e1da
move metrics tomb to global for now
blotus Jul 15, 2024
b865eec
remove configuration option for metrics interval
blotus Jul 15, 2024
8990cd8
fix usage_metrics endpoint to work with cert auth, add some tests
mmetc Jul 15, 2024
259d202
comments, lint
mmetc Jul 15, 2024
df4cd7e
set pushed metrics timestamp in utc; lint
mmetc Jul 15, 2024
9fe3b5f
remove test bouncer after use
mmetc Jul 15, 2024
b6c748e
Merge branch 'master' into lapi-detailed-metrics
buixor Jul 16, 2024
09f41cd
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 17, 2024
c9d307e
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 17, 2024
557096b
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 17, 2024
9609edb
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 18, 2024
4dc45ee
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 18, 2024
d1ffcac
properly init/reinit lpmetrics tomb
blotus Jul 18, 2024
3fe047f
Merge branch 'master' into lapi-detailed-metrics
blotus Jul 22, 2024
e6bf753
CI: update test dependencies (#3146)
mmetc Jul 22, 2024
51d6f84
long label for origin "cscli", "crowdsec"
mmetc Jul 22, 2024
2290ad2
Merge branch 'master' into lapi-detailed-metrics
mmetc Jul 22, 2024
a585ba0
dont' sum active_decisions
mmetc Jul 22, 2024
3af62dc
handle _gauge suffix on metrics names
mmetc Jul 23, 2024
bb8171a
explicitly de-duplicate raw metrics
mmetc Jul 23, 2024
7d790fe
collection timestamp can't be nil so warn
mmetc Jul 23, 2024
5517acf
always aggregate over ipv4+ipv6 (even in json output)
mmetc Jul 23, 2024
c68646b
extract method extractRawMetrics()
mmetc Jul 23, 2024
5b47ad3
extract aggegation methods
mmetc Jul 23, 2024
1187184
types for aggregated data
mmetc Jul 23, 2024
6448777
unroll map creation, extract more methods
mmetc Jul 23, 2024
9ad7a73
do not try to get console options for LP
blotus Jul 23, 2024
d7185a9
commends and dry
mmetc Jul 23, 2024
d5444b0
default value for received_at
blotus Jul 23, 2024
aeb3f08
lin/style
mmetc Jul 23, 2024
e55747a
mod tidy
mmetc Jul 23, 2024
01479b8
Revert "default value for received_at"
mmetc Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions cmd/crowdsec-cli/bouncers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,40 @@
"github.com/crowdsecurity/crowdsec/pkg/types"
)

type featureflagProvider interface {
GetFeatureflags() string
}

type osProvider interface {
GetOsname() string
GetOsversion() string
}

func getOSNameAndVersion(o osProvider) string {
ret := o.GetOsname()
if o.GetOsversion() != "" {
if ret != "" {
ret += "/"
}

Check warning on line 44 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L39-L44

Added lines #L39 - L44 were not covered by tests

ret += o.GetOsversion()

Check warning on line 46 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L46

Added line #L46 was not covered by tests
}

if ret == "" {
return "?"
}

Check warning on line 51 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L49-L51

Added lines #L49 - L51 were not covered by tests

return ret

Check warning on line 53 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L53

Added line #L53 was not covered by tests
}

func getFeatureFlagList(o featureflagProvider) []string {
if o.GetFeatureflags() == "" {
return nil
}

Check warning on line 59 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L56-L59

Added lines #L56 - L59 were not covered by tests

return strings.Split(o.GetFeatureflags(), ",")

Check warning on line 61 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L61

Added line #L61 was not covered by tests
}

func askYesNo(message string, defaultAnswer bool) (bool, error) {
var answer bool

Expand Down Expand Up @@ -137,8 +171,8 @@
Version: b.Version,
LastPull: b.LastPull,
AuthType: b.AuthType,
OS: b.GetOSNameAndVersion(),
Featureflags: b.GetFeatureFlagList(),
OS: getOSNameAndVersion(b),
Featureflags: getFeatureFlagList(b),

Check warning on line 175 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L174-L175

Added lines #L174 - L175 were not covered by tests
}
}

Expand Down Expand Up @@ -434,10 +468,10 @@
{"Version", bouncer.Version},
{"Last Pull", lastPull},
{"Auth type", bouncer.AuthType},
{"OS", bouncer.GetOSNameAndVersion()},
{"OS", getOSNameAndVersion(bouncer)},

Check warning on line 471 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L471

Added line #L471 was not covered by tests
})

for _, ff := range bouncer.GetFeatureFlagList() {
for _, ff := range getFeatureFlagList(bouncer) {

Check warning on line 474 in cmd/crowdsec-cli/bouncers.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/bouncers.go#L474

Added line #L474 was not covered by tests
t.AppendRow(table.Row{"Feature Flags", ff})
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/crowdsec-cli/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
hb = emoji.Warning + " " + hb
}

t.AppendRow(table.Row{m.MachineId, m.IpAddress, m.UpdatedAt.Format(time.RFC3339), validated, m.Version, m.GetOSNameAndVersion(), m.AuthType, hb})
t.AppendRow(table.Row{m.MachineId, m.IpAddress, m.UpdatedAt.Format(time.RFC3339), validated, m.Version, getOSNameAndVersion(m), m.AuthType, hb})

Check warning on line 206 in cmd/crowdsec-cli/machines.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/machines.go#L206

Added line #L206 was not covered by tests
}

fmt.Fprintln(out, t.Render())
Expand Down Expand Up @@ -236,8 +236,8 @@
Version: m.Version,
IsValidated: m.IsValidated,
AuthType: m.AuthType,
OS: m.GetOSNameAndVersion(),
Featureflags: m.GetFeatureFlagList(),
OS: getOSNameAndVersion(m),
Featureflags: getFeatureFlagList(m),

Check warning on line 240 in cmd/crowdsec-cli/machines.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/machines.go#L239-L240

Added lines #L239 - L240 were not covered by tests
Datasources: m.Datasources,
}
}
Expand Down Expand Up @@ -642,15 +642,15 @@
{"Last Heartbeat", machine.LastHeartbeat},
{"Validated?", machine.IsValidated},
{"CrowdSec version", machine.Version},
{"OS", machine.GetOSNameAndVersion()},
{"OS", getOSNameAndVersion(machine)},

Check warning on line 645 in cmd/crowdsec-cli/machines.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/machines.go#L645

Added line #L645 was not covered by tests
{"Auth type", machine.AuthType},
})

for dsName, dsCount := range machine.Datasources {
t.AppendRow(table.Row{"Datasources", fmt.Sprintf("%s: %d", dsName, dsCount)})
}

for _, ff := range machine.GetFeatureFlagList() {
for _, ff := range getFeatureFlagList(machine) {

Check warning on line 653 in cmd/crowdsec-cli/machines.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/machines.go#L653

Added line #L653 was not covered by tests
t.AppendRow(table.Row{"Feature Flags", ff})
}

Expand Down
44 changes: 30 additions & 14 deletions cmd/crowdsec-cli/metrics/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

"github.com/fatih/color"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"

"github.com/jedib0t/go-pretty/v6/table"
"github.com/jedib0t/go-pretty/v6/text"

"github.com/crowdsecurity/go-cs-lib/maptools"

Expand All @@ -32,31 +34,45 @@
})
}

switch cli.cfg().Cscli.Output {
outputFormat := cli.cfg().Cscli.Output

switch outputFormat {

Check warning on line 39 in cmd/crowdsec-cli/metrics/list.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/list.go#L37-L39

Added lines #L37 - L39 were not covered by tests
case "human":
t := cstable.New(color.Output, cli.cfg().Cscli.Color)
t.SetRowLines(true)
t.SetHeaders("Type", "Title", "Description")
out := color.Output
t := cstable.New(out, cli.cfg().Cscli.Color).Writer
t.AppendHeader(table.Row{"Type", "Title", "Description"})
t.SetColumnConfigs([]table.ColumnConfig{
{
Name: "Type",
AlignHeader: text.AlignCenter,
},
{
Name: "Title",
AlignHeader: text.AlignCenter,
},
{
Name: "Description",
AlignHeader: text.AlignCenter,
WidthMax: 60,
WidthMaxEnforcer: text.WrapSoft,
},
})
t.Style().Options.SeparateRows = true

Check warning on line 60 in cmd/crowdsec-cli/metrics/list.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/list.go#L41-L60

Added lines #L41 - L60 were not covered by tests

for _, metric := range allMetrics {
t.AddRow(metric.Type, metric.Title, metric.Description)
t.AppendRow(table.Row{metric.Type, metric.Title, metric.Description})

Check warning on line 63 in cmd/crowdsec-cli/metrics/list.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/list.go#L63

Added line #L63 was not covered by tests
}

t.Render()
fmt.Fprintln(out, t.Render())

Check warning on line 66 in cmd/crowdsec-cli/metrics/list.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/list.go#L66

Added line #L66 was not covered by tests
case "json":
x, err := json.MarshalIndent(allMetrics, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal metric types: %w", err)
}

fmt.Println(string(x))
case "raw":
x, err := yaml.Marshal(allMetrics)
if err != nil {
return fmt.Errorf("failed to marshal metric types: %w", err)
}

fmt.Println(string(x))
default:
return fmt.Errorf("output format '%s' not supported for this command", outputFormat)

Check warning on line 75 in cmd/crowdsec-cli/metrics/list.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/list.go#L74-L75

Added lines #L74 - L75 were not covered by tests
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/crowdsec-cli/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
cscli metrics list`,
Args: cobra.ExactArgs(0),
DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, _ []string) error {
return cli.show(nil, url, noUnit)
RunE: func(cmd *cobra.Command, _ []string) error {
return cli.show(cmd.Context(), nil, url, noUnit)

Check warning on line 42 in cmd/crowdsec-cli/metrics/metrics.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/metrics.go#L41-L42

Added lines #L41 - L42 were not covered by tests
},
}

Expand Down
9 changes: 7 additions & 2 deletions cmd/crowdsec-cli/metrics/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import (
"fmt"
"math"
"strconv"
)

type unit struct {
Expand All @@ -20,11 +21,15 @@
{value: 1, symbol: ""},
}

func formatNumber(num int) string {
func formatNumber(num int64, withUnit bool) string {
if !withUnit {
return strconv.FormatInt(num, 10)
}

Check warning on line 27 in cmd/crowdsec-cli/metrics/number.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/number.go#L24-L27

Added lines #L24 - L27 were not covered by tests

goodUnit := unit{}

for _, u := range ranges {
if int64(num) >= u.value {
if num >= u.value {

Check warning on line 32 in cmd/crowdsec-cli/metrics/number.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/number.go#L32

Added line #L32 was not covered by tests
goodUnit = u
break
}
Expand Down
23 changes: 18 additions & 5 deletions cmd/crowdsec-cli/metrics/show.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package metrics

import (
"context"
"errors"
"fmt"

log "github.com/sirupsen/logrus"

"github.com/fatih/color"
"github.com/spf13/cobra"

"github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli/require"
)

var (
ErrMissingConfig = errors.New("prometheus section missing, can't show metrics")
ErrMetricsDisabled = errors.New("prometheus is not enabled, can't show metrics")
)

func (cli *cliMetrics) show(sections []string, url string, noUnit bool) error {
func (cli *cliMetrics) show(ctx context.Context, sections []string, url string, noUnit bool) error {

Check warning on line 21 in cmd/crowdsec-cli/metrics/show.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/show.go#L21

Added line #L21 was not covered by tests
cfg := cli.cfg()

if url != "" {
Expand All @@ -30,8 +35,16 @@

ms := NewMetricStore()

if err := ms.Fetch(cfg.Cscli.PrometheusUrl); err != nil {
return err
// XXX: only on lapi
db, err := require.DBClient(ctx, cfg.DbConfig)
if err != nil {
// XXX how to handle this - if we are not on lapi, etc.
// we may read lp metrics without lapi?
log.Warnf("unable to open database: %s", err)
}

Check warning on line 44 in cmd/crowdsec-cli/metrics/show.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/show.go#L38-L44

Added lines #L38 - L44 were not covered by tests

if err := ms.Fetch(ctx, cfg.Cscli.PrometheusUrl, db); err != nil {
log.Warn(err)

Check warning on line 47 in cmd/crowdsec-cli/metrics/show.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/show.go#L46-L47

Added lines #L46 - L47 were not covered by tests
}

// any section that we don't have in the store is an error
Expand Down Expand Up @@ -90,9 +103,9 @@
cscli metrics show acquisition parsers scenarios stash -o json`,
// Positional args are optional
DisableAutoGenTag: true,
RunE: func(_ *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {

Check warning on line 106 in cmd/crowdsec-cli/metrics/show.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/show.go#L106

Added line #L106 was not covered by tests
args = expandAlias(args)
return cli.show(args, url, noUnit)
return cli.show(cmd.Context(), args, url, noUnit)

Check warning on line 108 in cmd/crowdsec-cli/metrics/show.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/metrics/show.go#L108

Added line #L108 was not covered by tests
},
}

Expand Down
Loading
Loading