Skip to content

Commit

Permalink
crowdsec: remove warning if prometheus port is taken during cold logs…
Browse files Browse the repository at this point in the history
… processing (#2857)

i.e. remove a "Warning: port is already in use" because it's probably LAPI
  • Loading branch information
mmetc committed Mar 7, 2024
1 parent 8108e41 commit 1eab943
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/crowdsec/crowdsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,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
5 changes: 4 additions & 1 deletion cmd/crowdsec/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ func servePrometheus(config *csconfig.PrometheusCfg, dbClient *database.Client,
log.Debugf("serving metrics after %s ms", time.Since(crowdsecT0))

if err := http.ListenAndServe(fmt.Sprintf("%s:%d", config.ListenAddr, config.ListenPort), nil); err != nil {
log.Warningf("prometheus: %s", err)
// in time machine, we most likely have the LAPI using the port
if !flags.haveTimeMachine() {
log.Warningf("prometheus: %s", err)
}
}
}

0 comments on commit 1eab943

Please sign in to comment.