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

[8.9](backport #35972) [filebeat] Check for duplicate ID for filestream metrics #35987

Merged
merged 1 commit into from
Jul 3, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Fix CEL input JSON marshalling of nested objects. {issue}35763[35763] {pull}35774[35774]
- Fix metric collection in GCPPubSub input. {pull}35773[35773]
- Fix end point deregistration in http_endpoint input. {issue}35899[35899] {pull}35903[35903]
- Fix duplicate ID panic in filestream metrics. {issue}35964[35964] {pull}35972[35972]

*Heartbeat*

Expand Down
3 changes: 2 additions & 1 deletion filebeat/input/filestream/internal/input-logfile/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

type managedInput struct {
userID string
metricsID string
manager *InputManager
ackCH *updateChan
sourceIdentifier *sourceIdentifier
Expand Down Expand Up @@ -61,7 +62,7 @@ func (inp *managedInput) Run(
defer cancel()
ctx.Cancelation = cancelCtx

metrics := NewMetrics(ctx.ID)
metrics := NewMetrics(inp.metricsID)
defer metrics.Close()

hg := &defaultHarvesterGroup{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,13 @@ func (cim *InputManager) Create(config *conf.C) (v2.Input, error) {
" duplication, please add an ID and restart Filebeat")
}

metricsID := settings.ID
cim.idsMux.Lock()
if _, exists := cim.ids[settings.ID]; exists {
cim.Logger.Errorf("filestream input with ID '%s' already exists, this "+
"will lead to data duplication, please use a different ID", settings.ID)
"will lead to data duplication, please use a different ID. Metrics "+
"collection has been disabled on this input.", settings.ID)
metricsID = ""
}

// TODO: improve how inputs with empty IDs are tracked.
Expand Down Expand Up @@ -223,6 +226,7 @@ func (cim *InputManager) Create(config *conf.C) (v2.Input, error) {
manager: cim,
ackCH: cim.ackCH,
userID: settings.ID,
metricsID: metricsID,
prospector: prospector,
harvester: harvester,
sourceIdentifier: sourceIdentifier,
Expand Down