feat(new transform): Add new incremental_to_absolute transform and change to MetricSet to an LRU cache with optional capacity policies#23374
Conversation
|
Hey @GreyLilac09, thanks for the PR. Please update the test plan in your description including a vector config and expected output. This part allows us to run your code with a config and easily validate what the expected output should look like. Here is an example config you can build on top of: or you can create one from scratch. Thanks! |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new incremental_to_absolute transform that converts incremental metrics to absolute metrics while preserving the cumulative values. This is useful for avoiding duplicate metric caches at sink levels and creating historical records for scenarios with lossy connections or file-based backfilling.
Key changes:
- Implements the core transform logic with TTL-based metric expiration
- Adds comprehensive documentation and configuration examples
- Includes unit tests covering incremental-to-absolute conversion and pass-through behavior for already-absolute metrics
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/transforms/incremental_to_absolute.rs |
Core implementation of the transform with metric conversion logic and tests |
website/cue/reference/components/transforms/incremental_to_absolute.cue |
Documentation and configuration reference for the new transform |
lib/vector-core/src/event/metric/data.rs |
Updates into_absolute() method to remove interval_ms when converting metrics |
src/transforms/mod.rs |
Registers the new transform module |
website/cue/reference/components.cue |
Adds feature definition for the transform |
Cargo.toml |
Adds feature flags for the new transform |
changelog.d/incremental_to_absolute_transform.feature.md |
Changelog entry documenting the new feature |
Comments suppressed due to low confidence (2)
website/cue/reference/components/transforms/incremental_to_absolute.cue:50
- The example title 'Aggregate over 5 seconds' is misleading. This transform converts incremental to absolute metrics but doesn't aggregate over time windows. A more accurate title would be 'Convert incremental counter to absolute'.
title: "Aggregate over 5 seconds"
website/cue/reference/components/transforms/incremental_to_absolute.cue
Outdated
Show resolved
Hide resolved
|
After thinking about this some more, I'm not so sure if just the
Thus, I would propose an additional configuration, eg where Alternatively, maybe it would just be better to group the cache configs like we do for Curious to hear your thoughts. I'd also eventually like to add this config to the prom remote write sink (eg from this PR). I can also do add the LRU cache in a separate PR, but it would not be ideal to change the config later (eg. go from |
Unfortunately, we are already outside the merge window. You can always use the nightly builds though which should be available one day after this PR is merged. |
|
@pront @thomasqueirozb Could you guys approve please? It's been ready for a while now |
…remental-to-absolute
|
@thomasqueirozb I think you need to approve? |
It's because |
|
just resolved the last one |
|
Thank you for this contribution @GreyLilac09! |
Summary
Create new incremental_to_absolute transform
Useful for:
Problem it solves: #23018
Vector configuration
How did you test this PR?
Example 1
Example configuration:
Example output:
Example 2
Enforcing max_events. Note that max_events = 1 means the other item will just be evicted immediately, resulting in 1 being received always in this example
Output:
Change Type
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.References
Notes
@vectordotdev/vectorto reach out to us regarding this PR.pre-pushhook, please see this template.cargo fmt --allcargo clippy --workspace --all-targets -- -D warningscargo nextest run --workspace(alternatively, you can runcargo test --all)git merge origin masterandgit push.Cargo.lock), pleaserun
cargo vdev build licensesto regenerate the license inventory and commit the changes (if any). More details here.