-
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
Add the take_over
mode for filestream inputs
#34292
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
|
7aed722
to
a1361ab
Compare
f828e16
to
d14a4f9
Compare
If a `filestream` input has the configuration parameter `take_over` set to `true`, every `loginput` state record (in the registry) with the `source` that matches at least one of the `filestream`'s paths/globs will be taken over by this `filestream` input. This means the existing `loginput` state entry gets converted into a `filestream` entry (the `loginput` entry gets deleted). The purpose of this mode is to make migration from `loginput` to `filestream` as simple and smooth as possible by adding `take_over: true` to the new `filestream` configuration. All offsets for input files will be preserved and the `filestream` will continue ingesting the files at the same point where the `loginput` stopped. This solves the previously occurring data duplication (file re-ingestion) problem.
d14a4f9
to
e3c577d
Compare
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
/test |
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.
Did a high level review and this looks really good! Very well described and documented.
I want to come back and manually test this before I give it a final approval.
Co-authored-by: Craig MacKenzie <craig.mackenzie@elastic.co>
This pull request is now in conflicts. Could you fix it? 🙏
|
Here there is an example: It's a function to enable/disable the logger based on the status of |
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.
A small comment about a error message, I believe it needs to be more precise. But I'm open to discuss if you thing differently ;)
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.
Tested locally and LGTM! Thanks! I really like the way this turned out. I did have one thought while I was testing this to follow up on.
I think it should be possible to set the take_over flag and execute it as a dry run where it shows you what paths it would take over without actually doing the migration. This will let people be confident that the filestream configuration they wrote only takes over what they actually want it to. I think this will be important when there are many log inputs in the same Filebeat instance. Thoughts @rdner? We don't have to do it for this PR but we can create a follow up issue and do it separately.
For the purposes of migration it would also be quite nice to define the new filestream and log inputs in the same configuration file and run them next to each other to compare the output. Probably this can more easily achieved by just running filebeat twice with two different configuration files and registry locations. Could we document how to set this up in the migration guide?
I think both of those options would make people feel more comfortable switching to filestream, because they can easily verify that their logs are harvested with the right format and that the filestream inputs they wrote will take over from the correct log inputs.
It may also be worth testing how long the take over mode takes for very large registries so we can set the expectations properly in the docs if it ends up taking a few minutes or something. |
@cmacknz I like the idea of having the dry-run mode but I'm yet to understand how to run it and get the results, it can be a separate command on the Filebeat binary that just outputs the results and exits. Otherwise, the result would be lost in logs.
Running I don't see how it brings any value.
|
If a `filestream` input has the configuration parameter `take_over` set to `true`, every `loginput` state record (in the registry) with the `source` that matches at least one of the `filestream`'s paths/globs will be taken over by this `filestream` input. This means the existing `loginput` state entry gets converted into a `filestream` entry (the `loginput` entry gets deleted). The purpose of this mode is to make migration from `loginput` to `filestream` as simple and smooth as possible by adding `take_over: true` to the new `filestream` configuration. All offsets for input files will be preserved and the `filestream` will continue ingesting the files at the same point where the `loginput` stopped. This solves the previously occurring data duplication (file re-ingestion) problem.
What does this PR do?
If a
filestream
input has the configuration parametertake_over
set totrue
, everyloginput
state record (in the registry) with thesource
that matches at least one of thefilestream
's paths/globs will be taken over by thisfilestream
input.This means the existing
loginput
state entry gets converted into afilestream
entry (theloginput
entry gets deleted).The purpose of this mode is to make migration from
loginput
tofilestream
as simple and smooth as possible by addingtake_over: true
to the newfilestream
configuration. All offsets for input files will be preserved and thefilestream
will continue ingesting the files at the same point where theloginput
stopped. This solves the previously occurring data duplication (file re-ingestion) problem.Out of scope
This does not address migration of any integration or other input type (like
container
#34393) that's using loginput under the hood. This addresses only the user facing migration fromlog
input tofilestream
input. The rest will follow later.Why is it important?
To improve UX of the loginput->filestream migration and allow all our integrations to smoothly migrate to filestream as well.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
loginput.log
with a few lines like this:filebeat-log.yml
for Filebeat:obviously, you'd need to replace
/path/to
with your test directory, including the following configs/commands below.You'll see the events on the console containing the lines from the log file:
filebeat-filestream.yml
(or follow the new migration guide):Wait for ~30 seconds, you should not see any new output on the console.
After a few seconds you should see the output on the console containing the added lines:
output-filestream.json
file created near the Filebeat binary, it should contain log objects with the take over process:This verifies that the
filestream
input took over the state from thelog
input, didn't duplicate events on startup and ingested new data from the original log file.Also, you can see that the registry log was backed up (
/path/to/data/registry/filebeat
, see the configs above):Related issues
log
input states tofilestream
#31749