Skip to content

fix(topology): remove metrics for retired components - #26144

Draft
Jansen-w wants to merge 1 commit into
vectordotdev:masterfrom
Jansen-w:fix/remove-retired-component-metrics
Draft

fix(topology): remove metrics for retired components#26144
Jansen-w wants to merge 1 commit into
vectordotdev:masterfrom
Jansen-w:fix/remove-retired-component-metrics

Conversation

@Jansen-w

Copy link
Copy Markdown
Contributor

Summary

Remove component-scoped internal metrics after a component is removed by a successful topology reload. Registry cleanup matches both component_id and component_kind, removes counters, gauges, and histograms, and clears their metric-recency bookkeeping so a later component with the same identity starts cleanly.

Cleanup runs only after the replacement topology is installed, preserving metrics when a reload fails and the previous topology is restored.

References

None.

Vector configuration

No new configuration is required. The regression test reloads a basic source-transform-sink topology after removing the transform.

How did you test this PR?

  • cargo test -p vector-core metrics::tests --no-default-features
  • cargo test -p vector --lib topology_removes_metrics_for_removed_component
  • cargo test -p vector --lib topology_remove_one_transform
  • cargo clippy -p vector-core --lib --tests --no-default-features -- -D warnings
  • cargo clippy -p vector --lib -- -D warnings
  • cargo fmt --all -- --check
  • cargo vdev check changelog-fragments

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. A changelog fragment is included.
  • No. A maintainer will apply the no-changelog label to this PR.

@github-actions github-actions Bot added domain: topology Anything related to Vector's topology code domain: core Anything related to core crates i.e. vector-core, core-common, etc labels Aug 18, 2026
Comment thread src/topology/running.rs
self.refresh_confinement_gauges();
let metrics = crate::metrics::Controller::get()
.expect("Metrics must be initialized before reloading the topology");
for (key, kind) in diff.removed_components() {

@gwenaskell gwenaskell Aug 19, 2026

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.

when we reach this breakpoint, a processor/sink removed from the topology may still be running and producing metrics. The topology runner only controls the state of sources, so trying to override the state of the metrics registry might cause unexpected behavior. The registry should automatically discard metrics after their TTL expired

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: core Anything related to core crates i.e. vector-core, core-common, etc domain: topology Anything related to Vector's topology code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants