-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: master
Are you sure you want to change the base?
Conversation
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>>, |
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.
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.
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.
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.
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.
Awesome 👍
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
Is this a breaking change?
How did you test this PR?
Test file field
Added a remap transform to config/vector.yaml :
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 files field
Added a remap transform to config/vector.yaml :
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.
Does this PR include user facing changes?
Notes
@vectordotdev/vector
to reach out to us regarding this PR.pre-push
hook, please see this template.cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
cargo nextest run --workspace
(alternatively, you can runcargo test --all
)./scripts/check_changelog_fragments.sh
git merge origin master
andgit push
.Cargo.lock
), pleaserun
cargo vdev build licenses
to regenerate the license inventory and commit the changes (if any). More details here.References