Skip to content

feat(remap transform): make --watch-config watch external VRL files in remap transforms #23010

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nekorro
Copy link

@nekorro nekorro commented May 8, 2025

Summary

This change ensures that updates to VRL source code are respected when calculating configuration diffs. External VRL files referenced in remap transforms (via file or files fields) are now tracked when --watch-config is enabled, allowing Vector to reload the configuration automatically when these files change.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

Test file field

Added a remap transform to config/vector.yaml :

transforms:
  remap_logs:
    type: remap
    file: vrl/vrl_one
    inputs:
      - demo_logs_one

Started Vector with vector -vvv -c config/vector.yaml -w
Then, modified the /vector/vrl/vrl_one file.
Vector detected the change and reloaded the configuration automatically as expected.
test_1

Test files field

Added a remap transform to config/vector.yaml :

transforms:
  remap_logs:
    type: remap
    files:
      - vrl/vrl_one
      - vrl/vrl_two
    inputs:
      - demo_logs_one

Started Vector with vector -vvv -c config/vector.yaml -w
Then, modified the /vector/vrl/vrl_two file.
Vector detected the change and reloaded the configuration automatically as expected.
test_2

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • The CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • cargo fmt --all
      • cargo clippy --workspace --all-targets -- -D warnings
      • cargo nextest run --workspace (alternatively, you can run cargo test --all)
      • ./scripts/check_changelog_fragments.sh
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run cargo vdev build licenses to regenerate the license inventory and commit the changes (if any). More details here.

References

@nekorro nekorro requested a review from a team as a code owner May 8, 2025 10:09
@bits-bot
Copy link

bits-bot commented May 8, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the domain: transforms Anything related to Vector's transform components label May 8, 2025
nekorro added 5 commits May 8, 2025 14:16
Calculate and store a hash of the VRL source to enable detection
ofchanges in the VRL code. This allows the configuration to be
reloadedautomatically when the VRL code is modified, even if it resides
in anexternal file.
Invoke the `files_to_watch` function for applicable transforms to
collectexternal file paths that should be watched for changes.
Add a `files_to_watch` function to the remap transform to collect file
pathsfrom the `file` and `files` fields. This allows to watch these
files forchanges and trigger reloads when the VRL code is modified.
/// This value is computed using the BLAKE3 hashing algorithm and is updated each time
/// a new VRL program is compiled via `compile_vrl_program`. This allows detecting changes
/// in the VRL code, enabling the configuration to be reloaded when modified.
pub vrl_hash: Mutex<Option<String>>,
Copy link
Member

Choose a reason for hiding this comment

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

If I am reading this changes correctly, we don't need vrl_hash at all. We certainly don't want it as a public config field. This will make a lot of boilerplate code redundant.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback.
You're right, I missed that ComponentConfig is used to match external file paths to component identifiers when reload happens. And it's possible to just pass the list of components to reload into ConfigDiff::new via the components_to_reload parameter. That makes vrl_hash unnecessary.
I also noticed the current implementation doesn't handle relative paths correctly.
I'll update this PR to remove vrl_hash and the related boilerplate, and fix the path comparison logic to support relative paths from the config.

Copy link
Member

Choose a reason for hiding this comment

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

Awesome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: transforms Anything related to Vector's transform components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make --watch-config respect remap source files
3 participants