Skip to content

Add support for bbolt-based storage in Filebeat#48879

Merged
rdner merged 34 commits into
elastic:mainfrom
rdner:filestream-bbolt-registry
Mar 2, 2026
Merged

Add support for bbolt-based storage in Filebeat#48879
rdner merged 34 commits into
elastic:mainfrom
rdner:filestream-bbolt-registry

Conversation

@rdner

@rdner rdner commented Feb 16, 2026

Copy link
Copy Markdown
Member

Proposed commit message

Add a new bbolt (BoltDB) storage backend for the Filebeat registry,
configurable via `filebeat.registry.backend: bbolt`. The bbolt backend
provides persistent on-disk storage with support for database compaction
and TTL-based entry cleanup.
This feature is experimental and may change or be removed in future releases.

Assisted by Cursor.

To see the registry content (debugging):

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.

Based on #48948 which needs to be merged first.

@rdner rdner self-assigned this Feb 16, 2026
@rdner rdner added Filebeat Filebeat backport-skip Skip notification from the automated backport with mergify Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team skip-changelog labels Feb 16, 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 Feb 16, 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!)
@github-actions

github-actions Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Vale Linting Results

Summary: 1 warning, 5 suggestions found

⚠️ Warnings (1)
File Line Rule Message
docs/reference/filebeat/configuration-general-options.md 114 Elastic.Latinisms Latin terms and abbreviations are a common source of confusion. Use 'and so on' instead of 'etc'.
💡 Suggestions (5)
File Line Rule Message
docs/reference/filebeat/configuration-general-options.md 114 Elastic.WordChoice Consider using 'can, might' instead of 'may', unless the term is in the UI.
docs/reference/filebeat/configuration-general-options.md 154 Elastic.WordChoice Consider using 'deactivates, deselects, hides, turns off, makes unavailable' instead of 'disables', unless the term is in the UI.
docs/reference/filebeat/configuration-general-options.md 154 Elastic.WordChoice Consider using 'deactivated, deselected, hidden, turned off, unavailable' instead of 'disabled', unless the term is in the UI.
docs/reference/filebeat/configuration-general-options.md 163 Elastic.WordChoice Consider using 'deactivates, deselects, hides, turns off, makes unavailable' instead of 'disables', unless the term is in the UI.
docs/reference/filebeat/configuration-general-options.md 163 Elastic.WordChoice Consider using 'deactivated, deselected, hidden, turned off, unavailable' instead of 'disabled', unless the term is in the UI.

The Vale linter checks documentation changes against the Elastic Docs style guide.

To use Vale locally or report issues, refer to Elastic style guide for Vale.

@github-actions

github-actions Bot commented Feb 20, 2026

Copy link
Copy Markdown
Contributor
@rdner rdner force-pushed the filestream-bbolt-registry branch from c922e3b to 538a845 Compare February 20, 2026 15:46

@rdner rdner left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added some clarifications on choice of constants.

Comment thread libbeat/statestore/backend/bbolt/bbolt.go
Comment thread libbeat/statestore/backend/bbolt/bbolt.go
Comment thread libbeat/statestore/backend/bbolt/bbolt.go
As an option, now Filebeat can be configured to store file offset
tracking in a bbolt storage instead of the WAL memlog implementation.

Also, improved the integration testing framework to accommodate
required checks for these changes.

Assisted by Cursor.
@rdner rdner force-pushed the filestream-bbolt-registry branch from 538a845 to 34786d8 Compare February 20, 2026 16:29
@rdner rdner requested a review from AndersonQ February 20, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libbeat/statestore/backend/bbolt/bbolt.go
@coderabbitai

coderabbitai Bot commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3aa50d and 8fe32d2.

📒 Files selected for processing (2)
  • libbeat/statestore/backend/bbolt/compaction.go
  • libbeat/statestore/backend/bbolt/store.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • libbeat/statestore/backend/bbolt/compaction.go

📝 Walkthrough

Walkthrough

Adds support for a new bbolt-backed registry backend for Filebeat selectable via filebeat.registry.backend (default memlog). Implements a bbolt Registry and per-store DBs, config structs for timeout, fsync, compaction, and TTL-based retention, and backend selection wiring in the store initialization. Includes compaction and retention logic, extensive docs and reference YAML updates, and integration and unit tests covering bbolt behavior.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@libbeat/statestore/backend/bbolt/compaction.go`:
- Line 35: The cleanup routine currently deletes every file matching the glob
tempDbPrefix + "*" (tempdb*), which can remove valid store DBs whose names begin
with "tempdb"; update the deletion logic in
libbeat/statestore/backend/bbolt/compaction.go to only remove true temporary DB
files by matching the exact naming convention used when creating temps (use a
stricter pattern such as tempDbPrefix followed by a fixed separator or
extension, e.g. tempdb_ or tempdb.<unique>.tmp, rather than tempdb*), and change
the code in the cleanup function (the block around where tempDbPrefix is used
for removal) to check for that exact separator/extension before unlinking files
so real store files like "<store>.db" are never deleted.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6bfbe86 and a3aa50d.

📒 Files selected for processing (14)
  • changelog/fragments/1771601358-add-bbolt-registry-backend.yaml
  • docs/reference/filebeat/configuration-general-options.md
  • docs/reference/filebeat/filebeat-reference-yml.md
  • filebeat/_meta/config/filebeat.global.reference.yml.tmpl
  • filebeat/beater/store.go
  • filebeat/config/config.go
  • filebeat/filebeat.reference.yml
  • filebeat/testing/integration/filestream_bbolt_test.go
  • libbeat/statestore/backend/bbolt/bbolt.go
  • libbeat/statestore/backend/bbolt/bbolt_test.go
  • libbeat/statestore/backend/bbolt/compaction.go
  • libbeat/statestore/backend/bbolt/config.go
  • libbeat/statestore/backend/bbolt/store.go
  • x-pack/filebeat/filebeat.reference.yml
Comment thread libbeat/statestore/backend/bbolt/compaction.go
@rdner rdner requested a review from belimawr February 27, 2026 12:29
Comment thread libbeat/statestore/backend/bbolt/store.go
Comment thread libbeat/statestore/backend/bbolt/compaction.go Outdated
Comment thread libbeat/statestore/backend/bbolt/store.go
@rdner rdner requested a review from orestisfl February 27, 2026 12:48
@rdner

rdner commented Feb 27, 2026

Copy link
Copy Markdown
Member Author

@orestisfl @belimawr @VihasMakwana @AndersonQ please focus on critical issues in your final review.

Just a reminder that this is an experimental feature which is built mainly for assessment and testing on our side. Any minor issues, refactoring, etc. can be contributed in later follow ups.

@orestisfl orestisfl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a reminder that this is an experimental feature which is built mainly for assessment and testing on our side. Any minor issues, refactoring, etc. can be contributed in later follow ups.

Fair. Code LGTM. Haven't focused much on config so an extra approval would be good here.

@rdner rdner requested a review from cmacknz February 27, 2026 13:03

@AndersonQ AndersonQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have a question about the RW mutex. I added the comments there

Comment thread libbeat/statestore/backend/bbolt/store.go
Comment thread libbeat/statestore/backend/bbolt/store.go
@rdner rdner requested a review from AndersonQ February 27, 2026 13:48

@orestisfl orestisfl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Quick note, should we feature-guard it with an environmental variable?

@rdner

rdner commented Feb 27, 2026

Copy link
Copy Markdown
Member Author

@orestisfl I think the configuration flag we introduced here is sufficient.

@AndersonQ AndersonQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks good. I left a comment, I think we need a default TTL, but it does not need to be addressed now.

Did you test it "under agent"? Is the bbolt db being copied to the agent diagnostics?

Comment thread docs/reference/filebeat/configuration-general-options.md
@rdner

rdner commented Feb 27, 2026

Copy link
Copy Markdown
Member Author

Did you test it "under agent"? Is the bbolt db being copied to the agent diagnostics?

No, I have not.

The bbolt storage is not included into the diagnostics yet and I don't think it should be in the scope of this PR. Only when we're committed to this feature at least at the technical preview level we can change this:

preFilesList := [][]string{
{"^registry$"},
{"^registry", "filebeat$"},
{"^registry", "filebeat", "meta\\.json$"},
{"^registry", "filebeat", "log\\.json$"},
{"^registry", "filebeat", "active\\.dat$"},
{"^registry", "filebeat", "[[:digit:]]*\\.json$"},

@cmacknz

cmacknz commented Feb 27, 2026

Copy link
Copy Markdown
Member

Before we fully integrate this into Elastic Agent we need to validate the effect it has. I am particularly interested in if our current schema and access patterns will work well with bbolt or if we have to change them - filelog does not use bbolt the same way we do.

So I am in agreement that we should get this merge and start the evaluation, if I have any comment before merge it's that we probably don't need to formally document it until we have learned how to use (yes it's experimental but we really don't intend for anyone to use it so why tell them about it now). That is not blocking though.

I don't think we need to be perfect in this PR, in fact widely using bbolt is impossible anyway until we have a way to migrate from registry to bbolt without breaking anything for users and can articulate the benefits of the change.

@rdner

rdner commented Feb 27, 2026

Copy link
Copy Markdown
Member Author

if I have any comment before merge it's that we probably don't need to formally document it until we have learned how to use (yes it's experimental but we really don't intend for anyone to use it so why tell them about it now).

The docs are already there (removing them is work, additional CI time) and they're to tell us developers about the currently available options. Judging by the amount of questions I got here about the available parameters, I'd rather keep it.

@belimawr

Copy link
Copy Markdown
Member

Did you test it "under agent"? Is the bbolt db being copied to the agent diagnostics?

No, I have not.

The bbolt storage is not included into the diagnostics yet and I don't think it should be in the scope of this PR. Only when we're committed to this feature at least at the technical preview level we can change this:

preFilesList := [][]string{
{"^registry$"},
{"^registry", "filebeat$"},
{"^registry", "filebeat", "meta\\.json$"},
{"^registry", "filebeat", "log\\.json$"},
{"^registry", "filebeat", "active\\.dat$"},
{"^registry", "filebeat", "[[:digit:]]*\\.json$"},

I think for testing and experimenting it is valuable to have the bbolt store in the diagnostics from the beginning, so if things go wrong and we collect a diagnostics, we have the bbolt db there.

However, I don't mind merging this PR without it.

@rdner rdner merged commit a7ff790 into elastic:main Mar 2, 2026
214 checks passed
@rdner rdner deleted the filestream-bbolt-registry branch March 2, 2026 08:15
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 Filebeat Filebeat Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

9 participants