Skip to content

filebeat/input/{v2,logv2}: add Redirector interface for general input migration#49613

Merged
efd6 merged 2 commits intoelastic:mainfrom
efd6:id6318-filebeat-director
Mar 31, 2026
Merged

filebeat/input/{v2,logv2}: add Redirector interface for general input migration#49613
efd6 merged 2 commits intoelastic:mainfrom
efd6:id6318-filebeat-director

Conversation

@efd6
Copy link
Copy Markdown
Contributor

@efd6 efd6 commented Mar 23, 2026

Proposed commit message

filebeat/input/{v2,logv2}: add Redirector interface for general input migration

Add an optional Redirector interface to the v2 input system so the
Loader can transparently redirect one input type to another. This
replaces the bespoke approach where logv2 directly imported and
instantiated the filestream plugin.

The Loader checks for Redirector before calling Create. If Redirect
returns a non-empty target type, the Loader resolves the target from
its plugin registry and calls its Create with the translated config.
Only one redirect hop is allowed. Delete follows the same redirect
path so CheckConfig cleanup operates on the correct target.

Refactor the logv2 manager to implement Redirector instead of holding
a direct reference to the filestream manager. This removes logv2's
import of the filestream package, eliminates a duplicate filestream
manager instance (and its redundant Init call), and makes the pattern
reusable for future V2-to-V2 migrations such as httpjson to cel.

Note

It may be worth reading the partner PR, #49614, to this to see its operation in context.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@efd6 efd6 self-assigned this Mar 23, 2026
@efd6 efd6 added enhancement Filebeat Filebeat backport-skip Skip notification from the automated backport with mergify Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:Security-Service Integrations Security Service Integrations Team labels Mar 23, 2026
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@belimawr belimawr self-requested a review March 23, 2026 22:25
@efd6 efd6 marked this pull request as ready for review March 24, 2026 00:39
@efd6 efd6 requested a review from a team as a code owner March 24, 2026 00:39
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@efd6 efd6 requested a review from VihasMakwana March 24, 2026 00:39
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@efd6 efd6 force-pushed the id6318-filebeat-director branch from 7fb1e17 to c0d3721 Compare March 24, 2026 00:42
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cfc770f4-7b5b-420c-a19d-a796cff5360a

📥 Commits

Reviewing files that changed from the base of the PR and between acbaa75 and e2463b5.

📒 Files selected for processing (1)
  • filebeat/input/logv2/input_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • filebeat/input/logv2/input_test.go

📝 Walkthrough

Walkthrough

Adds a redirect mechanism for Filebeat v2 inputs via a new exported Redirector interface allowing a manager to translate a requested input into a different target type and translated config. The logv2 inputs were refactored to remove direct filestream/statestore coupling and now use redirect semantics; LogPluginV2 and ContainerPluginV2 signatures no longer accept a statestore. The v2 loader resolves single-hop redirects during Configure and Delete and invokes the resolved target plugin with the translated config. Changelog fragment, README updates, unit tests, and test fakes for redirect/delete were added.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

… migration

Add an optional Redirector interface to the v2 input system so the
Loader can transparently redirect one input type to another. This
replaces the bespoke approach where logv2 directly imported and
instantiated the filestream plugin.

The Loader checks for Redirector before calling Create. If Redirect
returns a non-empty target type, the Loader resolves the target from
its plugin registry and calls its Create with the translated config.
Only one redirect hop is allowed. Delete follows the same redirect
path so CheckConfig cleanup operates on the correct target.

Refactor the logv2 manager to implement Redirector instead of holding
a direct reference to the filestream manager. This removes logv2's
import of the filestream package, eliminates a duplicate filestream
manager instance (and its redundant Init call), and makes the pattern
reusable for future V2-to-V2 migrations such as httpjson to cel.
@efd6 efd6 force-pushed the id6318-filebeat-director branch from c0d3721 to acbaa75 Compare March 24, 2026 00:53
@pierrehilbert pierrehilbert requested a review from rdner March 24, 2026 07:47
@chrisberkhout
Copy link
Copy Markdown
Contributor

@efd6 Is it correct that we separately pursued an approach where we'd migrate to cel but let it get old httpjson input cursor data? What's the status of that? Was that unsuccessful, or just incomplete, or is it not the same use case as this?

@efd6
Copy link
Copy Markdown
Contributor Author

efd6 commented Mar 26, 2026

This is essentially that, or at least an evolution of it (there was a shared state proposal that was abandoned, which may be what you are thinking of). There was an early, ugly, alternative approach that hid CEL in HTTP JSON. That has been abandoned as it was too ugly. There is also the non-cursor-state case that's handled by fleet; that is in parallel with this (I have notes for a KB article for how to use them together and when to do so).

The logic for the collection of HTTP JSON cursor state is in the partner PR.

Copy link
Copy Markdown
Contributor

@belimawr belimawr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR @efd6 !!

I left a small comment, definitely not blocking, so feel free to ignore if you don't agree ;)

@efd6 efd6 enabled auto-merge (squash) March 31, 2026 19:52
@efd6 efd6 merged commit 39bdcbe into elastic:main Mar 31, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-skip Skip notification from the automated backport with mergify enhancement Filebeat Filebeat Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:Security-Service Integrations Security Service Integrations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants