tikv / rust-prometheus

Prometheus instrumentation library for Rust applications
Apache License 2.0
1.07k stars 182 forks source link

Example for operations per second? #409

Closed vbmade2000 closed 2 years ago

vbmade2000 commented 3 years ago

Any idea on how to have a metric for the number of operations per second? Like a number of requests/second. I am using the rust-prometheus along with actix_web_prom to use it with Actix.

breezewish commented 3 years ago

Hi, you can just increase the counter every time you process an operation. Then Operations/Sec can be calculated by the Prometheus's rate() function. See https://prometheus.io/docs/prometheus/latest/querying/functions/#rate

vbmade2000 commented 3 years ago

Okay. So does it internally save timestamp too, with each count? Also, rate() function can be used in PromQL. Correct?

breezewish commented 3 years ago

Prometheus saves the timestamp during each scrape.

lucab commented 2 years ago

Tentatively closing this, as there doesn't seem to be a real bug here.