Limit usage of the deprecated log and container inputs#42295
Limit usage of the deprecated log and container inputs#42295rdner merged 15 commits intoelastic:mainfrom
log and container inputs#42295Conversation
The log input has been depredated since 7.16, it's time to disable it. The container input is just an alias/preset for the log input. They still can be used under the following circumstances: * When running under Elastic Agent (by integrations) * When running as a part of a module * When `allow_deprecated_use` is set as a part of the the input configuration
6401032 to
f1a1aa3
Compare
99d4d76 to
1f497a9
Compare
1f497a9 to
ba5df37
Compare
4fb2853 to
41e6772
Compare
508685e to
6de94ca
Compare
a9aa39c to
6aa00a4
Compare
| test: | ||
| enabled: true | ||
| wrong_field: error | ||
| var.paths: [] |
There was a problem hiding this comment.
This test was broken, this was missing and the test was expecting an error for empty paths.
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
belimawr
left a comment
There was a problem hiding this comment.
I'm just missing integration tests for both cases: standalone and under Elastic-Agent.
Co-authored-by: Tiago Queiroz <me@tiago.life>
Do we have any integration tests in Beats that run Elastic Agent and integrations? I'll work on the integration test for the standalone cases but I have doubts adding a test for Elastic Agent here would be the right place. |
There are bunch in beats/x-pack/filebeat/tests/integration/managerV2_test.go Lines 110 to 121 in 0b5cfa9 That you haven't had to change any of them might be enough, if you removed the fleetmode.Enabled check I'd expect some of those to fail. |
Yes, we do. Well, they don't run the Elastic-Agent, they mock the Elastic-Agent (via https://github.com/elastic/beats/blob/main/x-pack/filebeat/tests/integration/managerV2_test.go is a good starting point, the tests there have some extra complexity to assert state, but sending some configuration and asserting if Filebeat is behaving as expected is simple. You need to instantiate the server and implement To assess Filebeat's behaviour, looking at the logs or data shipped to the output usually is the easiest way. Ping me if you have any questions, need any help. |
|
This pull request is now in conflicts. Could you fix it? 🙏 |
The log input has been deprecated since 7.16, it's time to disable it. The container input is just an alias/preset for the log input.
They still can be used under the following circumstances:
allow_deprecated_useis set as a part of the the input configurationChecklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Disruptive User Impact
Users who are still using the deprecated
logandcontainerinputs in their hand-crafted configuration will see the error message on Filebeat's startup.How to test this PR locally
Running log input in the user-crafted configuration fails
filebeat.yml
This configuration produces the following error message:

Similar for the
containerinput:Setting
allow_deprecated_use: trueenables theloginputfilebeat.yml
These configurations run without the error.
loginput still runs as a part of a moduleFor example, the postgresql module is using the
loginput:beats/filebeat/module/postgresql/log/config/log.yml
Line 1 in ef3bd69
If we try to start this module via the configuration, Filebeat produces no error:
filebeat.yml
loginput still runs as a part of an integration (Elastic Agent)I ran the agent packaging with the Beats being on this branch:
Verified that the packaged
agentbeatcontains the code from this branch:filebeat.yml
and it failed as expected:
I use "Custom Logs" integration for the next test because it's based on the log input:
https://github.com/elastic/integrations/blob/a957144c41043e28e7effa343d4619f00f4deef3/packages/log/manifest.yml#L19
I created a cloud deployment and enrolled my custom agent to the Fleet with the "Custom Logs" integration.
{ "info": { "id": "bbc5aff6-81db-421c-b674-5dcdf6e67d16", "version": "9.0.0", "commit": "c7c5ba4132605f9bdef4b1bd63ab6337fef4abba", "build_time": "2025-01-17 12:36:46 +0000 UTC", "snapshot": true, "pid": 85790, "unprivileged": false, "is_managed": true }, "state": 2, "message": "Running", "components": [ { "id": "log-default", "name": "log", "state": 2, "message": "Healthy: communicating with pid '85831'", "units": [ { "unit_id": "log-default", "unit_type": 1, "state": 2, "message": "Healthy" }, { "unit_id": "log-default-logfile-logs-e9751ac9-bb83-4573-a41a-3824f423aa37", "unit_type": 0, "state": 2, "message": "Healthy", "payload": { "streams": { "logfile-log.logs-e9751ac9-bb83-4573-a41a-3824f423aa37": { "error": "", "status": "HEALTHY" } } } } ], "version_info": { "name": "beat-v2-client", "meta": { "build_time": "2025-01-17 12:32:44 +0000 UTC", "commit": "265dda891e5bc6f9b7dbe7e417917ab2ba11d4e7" } } } ], "FleetState": 2, "FleetMessage": "Connected" }I saw in the logs that the log input was running
{ "log.level": "debug", "@timestamp": "2025-01-17T13:15:38.405Z", "message": "Run input", "component": { "binary": "filebeat", "dataset": "elastic_agent.filebeat", "id": "log-default", "type": "log" }, "log": { "source": "log-default" }, "service.name": "filebeat", "ecs.version": "1.6.0", "log.logger": "input", "log.origin": { "file.line": 149, "file.name": "input/input.go", "function": "github.com/elastic/beats/v7/filebeat/input.(*Runner).Run" } } { "log.level": "debug", "@timestamp": "2025-01-17T13:15:38.405Z", "message": "Start next scan", "component": { "binary": "filebeat", "dataset": "elastic_agent.filebeat", "id": "log-default", "type": "log" }, "log": { "source": "log-default" }, "log.logger": "input", "log.origin": { "file.line": 246, "file.name": "log/input.go", "function": "github.com/elastic/beats/v7/filebeat/input/log.(*Input).Run" }, "service.name": "filebeat", "input_id": "fd29f73b-9e51-4c3e-8133-1d7a6f807732", "ecs.version": "1.6.0" } { "log.level": "debug", "@timestamp": "2025-01-17T13:15:38.418Z", "message": "Check file for harvesting: /Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log", "component": { "binary": "filebeat", "dataset": "elastic_agent.filebeat", "id": "log-default", "type": "log" }, "log": { "source": "log-default" }, "input_id": "fd29f73b-9e51-4c3e-8133-1d7a6f807732", "ecs.version": "1.6.0", "log.logger": "input", "log.origin": { "file.line": 494, "file.name": "log/input.go", "function": "github.com/elastic/beats/v7/filebeat/input/log.getFileState" }, "service.name": "filebeat" } { "log.level": "debug", "@timestamp": "2025-01-17T13:15:38.418Z", "message": "Update existing file for harvesting: /Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log, offset: 0", "component": { "binary": "filebeat", "dataset": "elastic_agent.filebeat", "id": "log-default", "type": "log" }, "log": { "source": "log-default" }, "state_id": "native::210784429-16777233", "os_id": "210784429-16777233", "source_file": "/Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log", "old_finished": false, "ecs.version": "1.6.0", "input_id": "fd29f73b-9e51-4c3e-8133-1d7a6f807732", "log.logger": "input", "log.origin": { "file.line": 593, "file.name": "log/input.go", "function": "github.com/elastic/beats/v7/filebeat/input/log.(*Input).harvestExistingFile" }, "old_source": "/Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log", "service.name": "filebeat", "finished": false, "old_os_id": "210784429-16777233" } { "log.level": "debug", "@timestamp": "2025-01-17T13:15:38.418Z", "message": "Harvester for file is still running: /Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log", "component": { "binary": "filebeat", "dataset": "elastic_agent.filebeat", "id": "log-default", "type": "log" }, "log": { "source": "log-default" }, "service.name": "filebeat", "input_id": "fd29f73b-9e51-4c3e-8133-1d7a6f807732", "os_id": "210784429-16777233", "source_file": "/Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log", "state_id": "native::210784429-16777233", "old_finished": false, "finished": false, "old_source": "/Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log", "ecs.version": "1.6.0", "log.logger": "input", "log.origin": { "file.line": 648, "file.name": "log/input.go", "function": "github.com/elastic/beats/v7/filebeat/input/log.(*Input).harvestExistingFile" }, "old_os_id": "210784429-16777233" } { "log.level": "debug", "@timestamp": "2025-01-17T13:15:38.418Z", "message": "input states cleaned up. Before: 1, After: 1, Pending: 0", "component": { "binary": "filebeat", "dataset": "elastic_agent.filebeat", "id": "log-default", "type": "log" }, "log": { "source": "log-default" }, "log.logger": "input", "log.origin": { "file.line": 310, "file.name": "log/input.go", "function": "github.com/elastic/beats/v7/filebeat/input/log.(*Input).cleanupStates" }, "service.name": "filebeat", "input_id": "fd29f73b-9e51-4c3e-8133-1d7a6f807732", "ecs.version": "1.6.0" } { "log.level": "debug", "@timestamp": "2025-01-17T13:15:43.378Z", "message": "End of file reached: /Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log; Backoff now.", "component": { "binary": "filebeat", "dataset": "elastic_agent.filebeat", "id": "log-default", "type": "log" }, "log": { "source": "log-default" }, "input_id": "fd29f73b-9e51-4c3e-8133-1d7a6f807732", "finished": false, "harvester_id": "ce7d846b-bddc-4fa0-8af5-1b3af845775f", "log.origin": { "file.line": 111, "file.name": "log/log.go", "function": "github.com/elastic/beats/v7/filebeat/input/log.(*Log).Read" }, "service.name": "filebeat", "source_file": "/Users/rdner/Projects/es_confs/deprecate_log/logs/log1.log", "state_id": "native::210784429-16777233", "os_id": "210784429-16777233", "ecs.version": "1.6.0", "log.logger": "input.harvester" }I saw the incoming data in Kibana too: