hashicorp / vault

A tool for secrets management, encryption as a service, and privileged access management
https://www.vaultproject.io/
Other
30.99k stars 4.19k forks source link

Support float64 gauge metrics #19594

Open rzimmerman opened 1 year ago

rzimmerman commented 1 year ago

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: https://github.com/hashicorp/vault/blob/2dd4528ed8a8be83e0c1e0b48b1f23dab701181f/builtin/logical/pki/path_tidy.go#L1209

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: https://github.com/hashicorp/go-metrics/issues/150

biazmoreira commented 1 year ago

Blocked by https://github.com/hashicorp/vault/pull/21130