prometheus-cpp icon indicating copy to clipboard operation
prometheus-cpp copied to clipboard

Expiring Metrics

Open mfine opened this issue 5 years ago • 6 comments

Some other prometheus exporters expire metrics. For example:

https://github.com/prometheus/statsd_exporter#time-series-expiration https://github.com/prometheus/statsd_exporter/blob/master/exporter.go#L447

We'd like to see support for this in prometheus-cpp and would be happy to add it. Any guidance around going about integrating it? Thanks!

mfine avatar Apr 06 '19 00:04 mfine

This is not something that client libraries should generally provide, a child should in principle have the same lifecycle as the process.

brian-brazil avatar Aug 06 '19 15:08 brian-brazil

@brian-brazil we picked this functionality up with statsd_exporter and are continuing to use it directly in this library - checkout our branch if you're interested in this functionality: https://github.com/jupp0r/prometheus-cpp/compare/master...swift-nav:master.

mfine avatar Aug 06 '19 16:08 mfine

Thanks for chiming in @brian-brazil. My general understanding is that dynamically creating and removing metrics is discouraged because the prometheus servers data model assumes the number of metrics to be constant per scrape target. Has that changed in 2.x?

jupp0r avatar Aug 06 '19 18:08 jupp0r

Discouraged yes, however dynamically creating is fairly standard (if abused at times).

brian-brazil avatar Aug 06 '19 18:08 brian-brazil

Would someone be able to elaborate on why this practice is discouraged? Thanks!

PS. For our application, we have metrics that are labelled with phases. Our process progresses from one phase to the next and never revisits the previous phases. So, expiring these metrics would get us some savings.

fcimeson avatar Dec 13 '19 19:12 fcimeson

This would be very useful.

fluffy avatar Sep 13 '21 00:09 fluffy