I am using ElasticSearch as a data source in Grafana. I have an ES index in which every document represents an HTTP request. I would like to create a graph that would show the rate of request in a given time interval (per second, per minute).
Basically, I am hoping it is possible to reproduce what prometheus offer with the rate()
function: https://prometheus.io/docs/prometheus/latest/querying/functions/#rate
Per my actual researches, I think I should use the "derivative" option in Grafana, associated with the Count metric, but I am not sure how to configure it to graph correct results.
Furthermore, I am using a templated interval
variable with custom intervals like 2m, 3m... Would it be possible to use $__interval_ms
builtin variable to compute the rate. I mean, is this builtin automatically computed based my custom interval, or is it working only with the auto
value? If not, how would I usea time interval like 5m
to perform arithmetic to compute the rate from it ?
Thanks
Solved this by adding a dummy field for each request I log, where the content is simply the value 1. Then in grafana, I can use the sum
aggregator and an inline script that allow me to calculate a rate given a time interval like 5m, where the script is simply *value / 60*5*.