Skip to content

Commit

Permalink
crowdsec: disable prometheus metrics when running time machine
Browse files Browse the repository at this point in the history
...to avoid port conflict warning, also change "acquisition is finished" to Info
  • Loading branch information
mmetc committed Feb 23, 2024
1 parent e34af35 commit 93726d0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/crowdsec/crowdsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func waitOnTomb() {
case <-acquisTomb.Dead():
/*if it's acquisition dying it means that we were in "cat" mode.
while shutting down, we need to give time for all buckets to process in flight data*/
log.Warning("Acquisition is finished, shutting down")
log.Info("Acquisition is finished, shutting down")
/*
While it might make sense to want to shut-down parser/buckets/etc. as soon as acquisition is finished,
we might have some pending buckets: buckets that overflowed, but whose LeakRoutine are still alive because they
Expand Down
4 changes: 4 additions & 0 deletions cmd/crowdsec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ type Flags struct {
CpuProfile string
}

func (f *Flags) haveTimeMachine() bool {
return f.OneShotDSN != ""
}

type labelsMap map[string]string

func LoadBuckets(cConfig *csconfig.Config, hub *cwhub.Hub) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/crowdsec/run_in_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func StartRunSvc() error {
agentReady := make(chan bool, 1)

// Enable profiling early
if cConfig.Prometheus != nil {
if cConfig.Prometheus != nil && !flags.haveTimeMachine() {
var dbClient *database.Client

var err error
Expand Down
2 changes: 1 addition & 1 deletion cmd/crowdsec/run_in_svc_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func WindowsRun() error {
agentReady := make(chan bool, 1)

// Enable profiling early
if cConfig.Prometheus != nil {
if cConfig.Prometheus != nil && !flags.haveTimeMachine() {
var dbClient *database.Client
var err error

Expand Down

0 comments on commit 93726d0

Please sign in to comment.