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

crowdsec: remove warning if prometheus port is taken during cold logs processing #2857

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion cmd/crowdsec/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,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)
}
}
}