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

Support float64 gauge metrics #19594

Open
rzimmerman opened this issue Mar 16, 2023 · 1 comment
Open

Support float64 gauge metrics #19594

rzimmerman opened this issue Mar 16, 2023 · 1 comment
Labels
core/metric core Issues and Pull-Requests specific to Vault Core enhancement

Comments

@rzimmerman
Copy link

Is your feature request related to a problem? Please describe.
It can be useful to report Unix timestamps as gauge metrics. For Prometheus, the recommended unit is Unix timestamps (in seconds) https://prometheus.io/docs/practices/naming/. Vault uses the go-metrics library which stores metrics as float32s, later upcast for Prometheus. For Unix times, this isn't enough precision (https://go.dev/play/p/RvJ11Y8R7Cz) and truncates the value to about ~2 minute precision.

Vault has at least one instance of this, probably unnoticed:

metrics.SetGauge([]string{"secrets", "pki", "tidy", "start_time_epoch"}, float32(b.tidyStatus.timeStarted.Unix()))

Describe the solution you'd like
Either update go-metrics to use float64 values, or add a Gauge64 (something like this fork https://github.com/rcrowley/go-metrics/blob/cf1acfcdf4751e0554ffa765d03e479ec491cad6/gauge_float64.go)

Describe alternatives you've considered
Storing timestamps with a different epoch would work, but be difficult to integrate with tools like Grafana. It also just kicks the can down the road.
Recording the metric as a "time since event"/"age" would also work, but is brittle in cases where metrics have gaps.

Explain any additional use-cases
Specifically for Vault Agent, it is useful to record things like last authentication time and other timestamps for alerting.

go-metrics issue opened here: hashicorp/go-metrics#150

@biazmoreira biazmoreira added core/metric core Issues and Pull-Requests specific to Vault Core enhancement labels Mar 22, 2023
@biazmoreira
Copy link
Contributor

Blocked by #21130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core/metric core Issues and Pull-Requests specific to Vault Core enhancement
Projects
None yet
Development

No branches or pull requests

2 participants