-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
filebeat stateful inputs - remove source name from context.ID #38603
filebeat stateful inputs - remove source name from context.ID #38603
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
d0e12a6
to
a22037a
Compare
For stateful inputs the context.ID is modified by appending the source name (as returned by the input-cursor.Source#Name method). This creates an inconsistency in behavior between stateless and stateful inputs. I found the behavior to be surprising because the ID is user-configurable, but the user's configured value gets mutated (and only for some inputs types). So I think the clearest solution is to stop appending the source name. From analyzing each of the stateful inputs that will be affected by this change, none of them use the ID is manner that will be affected. The value only appears to be used in log messages, metrics, or http tracer file names. | Stateful Input | context.ID usages | |----------------------------------------|-------------------------------------| | filebeat/input/filestream | log message | | filebeat/input/journald | not used | | filebeat/input/winlog | not used | | x-pack/filebeat/input/awss3 | metric ID | | x-pack/filebeat/input/azureblobstorage | not used | | x-pack/filebeat/input/cel | metric ID and http tracer file name | | x-pack/filebeat/input/gcs | not used | | x-pack/filebeat/input/httpjson | metric ID and http tracer file name | | x-pack/filebeat/input/o365audit | not used | | x-pack/filebeat/input/shipper | not used | | x-pack/filebeat/input/websocket | metric ID | The cursor ID that is written into the registry is constructed independent of the context.ID so it should not be affected. See https://github.com/elastic/beats/blob/78dc6649400610e9f908af7c90f35819f061e4e0/filebeat/input/v2/input-cursor/input.go#L171-L176
Always call the context.CancelFunc function to stop the running input in the case of a test failure. This ensures that any resources associated with the input are freed.
input_integration_test.go:324:16: Error return value of `writer.Write` is not checked (errcheck) writer.Write(line) ^ input_integration_test.go:1036:11: Error return value of `f.Write` is not checked (errcheck) f.Write([]byte(fmt.Sprintf("hello world %d\n", r*iterations+n)))
287c1d8
to
ed68e73
Compare
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least for Filestream, this will affect our ability to debug issues, there are some places where the context.ID
it gets logged alongside errors, and the ID allows us to know the affected files instead of just having a generic "Filestream".
Some examples:
beats/filebeat/input/filestream/internal/input-logfile/harvester.go
Lines 141 to 145 in 1031241
if err := hg.tg.Go(startHarvester(ctx, hg, src, false, hg.metrics)); err != nil { | |
ctx.Logger.Warnf( | |
"tried to start harvester with task group already closed", | |
ctx.ID) | |
} |
beats/filebeat/input/filestream/internal/input-logfile/harvester.go
Lines 280 to 284 in 1031241
if err != nil { | |
ctx.Logger.Warnf( | |
"input %s tried to Continue harvester with task group already closed", | |
ctx.ID) | |
} |
beats/filebeat/input/filestream/internal/input-logfile/harvester.go
Lines 158 to 162 in 1031241
if err := hg.tg.Go(startHarvester(ctx, hg, src, true, hg.metrics)); err != nil { | |
ctx.Logger.Warnf( | |
"input %s tried to restart harvester with task group already closed", | |
ctx.ID) | |
} |
The inputs that use this for metric name the TCP input
beats/filebeat/input/tcp/input.go
Line 102 in 1031241
metrics := netmetrics.NewTCP("tcp", ctx.ID, s.config.Host, pollInterval, log) |
I agree standardisation is good, but on this case I am really concerned by the side effects.
I looked at the linked issue, and just changing how input IDs are created does not seem to be a robust solution for me. Therefore I'm not quite sure the benefits of this change.
The goal of this PR has now been accomplished in #40909 through a change that does not affect the existing |
Proposed commit message
For stateful inputs the context.ID is modified by appending the source name (as returned by the input-cursor.Source#Name method). This creates an inconsistency in behavior between stateless and stateful inputs.
I found the behavior to be surprising because the ID is user-configurable, but the user's configured value gets mutated (and only for some inputs types). So I think the clearest solution is to stop appending the source name.
From analyzing each of the stateful inputs that will be affected by this change, none of them use the ID is manner that will be affected. The value only appears to be used in log messages, metrics, or http tracer file names.
The cursor ID that is written into the registry is constructed independent of the context.ID so it should not be affected. See
beats/filebeat/input/v2/input-cursor/input.go
Lines 171 to 176 in 78dc664
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues