Vault Monitoring Metrics Using "v1/sys/metrics"

Hi Team,
I am working on monitoring Vault using rest api based approach. We are getting these metrics in json format using “v1/sys/metrics” rest api. I am getting metrics when I perform any operations on Vault. I am not able to get any metrics for specific period. I mean I want to get last 2 hours or 3 hours or 2 days metrics. I don’t want to use Prometheus format metrics. Also I observed that JSON and Prometheus is giving different results.

Could you please help how to get specific period metrics in json format? Is it way to pass startime and end time to “v1/sys/metrics” api to get metrics in that period ? Or is it any way to store metrics in memory for spefic time period ?

Thanks,
Sunil

Hi, Sunil.

The /sys/metrics endpoint is only a polling endpoint that retrieves the current metrics. The in-memory statistics (returned when you ask for the JSON format) are retained for one minute, while Prometheus has a configurable retention period (that defaults to 24 hours.)

Vault does not have any sort of internal time-series database that would permit queries for older telemetry. Our recommended model is that you stream data using the StatsD format. Our monitoring guides show how to set this up with Telegraf, InfluxDB, and Grafana (https://learn.hashicorp.com/tutorials/vault/monitoring) or Telegraf and Splunk (https://learn.hashicorp.com/tutorials/vault/monitor-telemetry-audit-splunk) Other monitoring solutions like DataDog or Prometheus also work.

If you’re going to build your own monitoring solution that polls the REST api, you will have to poll on a regular interval and store the data in a separate database.

Thank you very much for it. I’ll be looking into Prometheus.