Skip to content

Commit 6a73994

Browse files
authored
replace prom2json with native Prometheus parser and context-aware scraping in CLI metrics (#3932)
* deps: update prometheus client * remove dependency on prom2json * lint: protogetter
1 parent 2694ffa commit 6a73994

File tree

7 files changed

+313
-437
lines changed

7 files changed

+313
-437
lines changed

cmd/crowdsec-cli/cliitem/cmdinspect.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (cli *cliItem) inspect(ctx context.Context, args []string, url string, diff
6464

6565
wantMetrics := !noMetrics && item.State.IsInstalled()
6666

67-
if err := inspectItem(hub, item, wantMetrics, cfg.Cscli.Output, cfg.Cscli.PrometheusUrl, cfg.Cscli.Color); err != nil {
67+
if err := inspectItem(ctx, hub, item, wantMetrics, cfg.Cscli.Output, cfg.Cscli.PrometheusUrl, cfg.Cscli.Color); err != nil {
6868
return err
6969
}
7070

@@ -200,7 +200,7 @@ func (cli *cliItem) newInspectCmd() *cobra.Command {
200200
return cmd
201201
}
202202

203-
func inspectItem(hub *cwhub.Hub, item *cwhub.Item, wantMetrics bool, output string, prometheusURL string, wantColor string) error {
203+
func inspectItem(ctx context.Context, hub *cwhub.Hub, item *cwhub.Item, wantMetrics bool, output string, prometheusURL string, wantColor string) error {
204204
// This is dirty...
205205
// We want to show current dependencies (from content), not latest (from index).
206206
// The item is modifed but after this function the whole hub should be thrown away.
@@ -235,7 +235,7 @@ func inspectItem(hub *cwhub.Hub, item *cwhub.Item, wantMetrics bool, output stri
235235
if wantMetrics {
236236
fmt.Fprint(os.Stdout, "\nCurrent metrics: \n")
237237

238-
if err := showMetrics(prometheusURL, hub, item, wantColor); err != nil {
238+
if err := showMetrics(ctx, prometheusURL, hub, item, wantColor); err != nil {
239239
return err
240240
}
241241
}

0 commit comments

Comments
 (0)