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

metrics: add machine label to "cs_active_decisions" #120

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions cmd/crowdsec/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
Name: "cs_active_decisions",
Help: "Number of active decisions.",
},
[]string{"reason", "origin", "action"},
[]string{"reason", "origin", "action", "machine"},
)

var globalAlerts = prometheus.NewGaugeVec(
Expand Down Expand Up @@ -125,8 +125,15 @@

globalActiveDecisions.Reset()

machine := "XXX" // how to get the machine id?

for _, d := range decisions {
globalActiveDecisions.With(prometheus.Labels{"reason": d.Scenario, "origin": d.Origin, "action": d.Type}).Set(float64(d.Count))
globalActiveDecisions.With(prometheus.Labels{
"reason": d.Scenario,
"origin": d.Origin,
"action": d.Type,
"machine": machine,
}).Set(float64(d.Count))

Check warning on line 136 in cmd/crowdsec/metrics.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec/metrics.go#L131-L136

Added lines #L131 - L136 were not covered by tests
}

globalAlerts.Reset()
Expand Down
Loading