fix(prometheus_exporter sink): allow disabling metric expiration via flush_period_secs=0 - #26041
Open
valerypetrov wants to merge 4 commits into
Open
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
valerypetrov
force-pushed
the
fix/prometheus-exporter-disable-expiration
branch
from
August 5, 2026 22:12
9633c14 to
d3092df
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9633c14297
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Author
|
recheck |
…flush_period_secs=0 Metrics in the prometheus_exporter sink are expired after flush_period_secs of no updates. For metrics with sparse or bursty updates (e.g. high cardinality counters produced by log_to_metric), this causes them to be expired and later re-added as a "new" series, which appears to Prometheus as a gap followed by a counter reset, even when flush_period_secs is configured very high. This under-counts increase()/rate() queries that span the gap. Allow flush_period_secs to be set to 0 to disable expiration entirely, so metrics persist for the lifetime of the sink instead of being evicted. Fixes: vectordotdev#23519
…eriod_secs Updates the generated cue reference for flush_period_secs to describe the new 0-disables-expiration behavior, keeping it in sync with the Rust doc comment.
valerypetrov
force-pushed
the
fix/prometheus-exporter-disable-expiration
branch
from
August 5, 2026 22:21
b35a4d5 to
407454d
Compare
Author
|
recheck |
Author
|
@jszwedko , can you please check this one? |
Contributor
|
Hi @valerypetrov ! Tagging @vectordotdev/vector since I'm not actively involved in the project anymore. |
Member
|
Thanks @valerypetrov we will take a look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #23519.
The
prometheus_exportersink expires a metric series once it hasn't been updated forflush_period_secs. For metrics with sparse or bursty updates — e.g. high-cardinality counters produced bylog_to_metricwith tags likepod/status/downstream_service— this causes a series to be expired and later re-added as if it were brand new. To Prometheus, this looks like a gap followed by a counter reset, even whenflush_period_secsis configured very high (the reporter tried 1 hour). Anyincrease()/rate()query spanning that gap under-counts, which is exactly the discrepancy described in the issue versus a Loki-basedcount_over_time()reference query.This mirrors a long-standing, maintainer-acknowledged feature request in #10424 ("decouple prometheus_exporter expiration from flush period" / disable expiration), which had a prior attempt in #10427 that went stale and was closed without merging.
flush_period_secs: 0now disables metric expiration entirely instead of being rejected at config-build time. Metrics then persist for the lifetime of the sink.MetricMetadata::has_expiredtreats a zero expiration window as "never expires".PrometheusExporter::runis skipped entirely when expiration is disabled, avoiding an unnecessary full map scan on every event.build()emits awarn!when expiration is disabled, noting the unbounded memory growth risk if metric series cardinality is unbounded.flush_period_secsupdated to describe the0behavior.