Skip to content
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

Make prometheus serializer update timestamps and expiration time as new data arrives #9139

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugins/serializers/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ use the `metric_version = 2` option in order to properly round trip metrics.
not be correct if the metric spans multiple batches. This issue can be
somewhat, but not fully, mitigated by using outputs that support writing in
"batch format". When using histogram and summary types, it is recommended to
use only the `prometheus_client` output.
use only the `prometheus_client` output. Histogram and Summary types
also update their expiration time based on the most recently received data.
If incoming metrics stop updating specific buckets or quantiles but continue
reporting others every bucket/quantile will continue to exist.


### Configuration

Expand Down
6 changes: 6 additions & 0 deletions plugins/serializers/prometheus/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ func (c *Collection) Add(metric telegraf.Metric, now time.Time) {
AddTime: now,
Histogram: &Histogram{},
}
} else {
m.Time = metric.Time()
m.AddTime = now
}
switch {
case strings.HasSuffix(field.Key, "_bucket"):
Expand Down Expand Up @@ -289,6 +292,9 @@ func (c *Collection) Add(metric telegraf.Metric, now time.Time) {
AddTime: now,
Summary: &Summary{},
}
} else {
m.Time = metric.Time()
m.AddTime = now
}
switch {
case strings.HasSuffix(field.Key, "_sum"):
Expand Down
Loading