Calculating request per second using InfluxDB on Grafana

jk2K picture jk2K · Jun 4, 2016 · Viewed 11k times · Source

I use telegraf plugin nginx to read Nginx's basic status information (ngx_http_stub_status_module)

This is my query

request per second query

raw sql:

SELECT derivative(mean("requests"), 1s) FROM "nginx" WHERE $timeFilter GROUP BY time($interval) fill(null)

This is my data

time            accepts active  handled host    port    reading requests    server      waitingwriting
1464921070000000000 7   1   7   hysm    80  0   17      localhost   0   1
1464921080000000000 8   1   8   hysm    80  0   19      localhost   0   1
1464921090000000000 8   1   8   hysm    80  0   20      localhost   0   1
1464921100000000000 8   1   8   hysm    80  0   21      localhost   0   1

but requestPerSecond is 0.083, what is wrong with my query?

request per second graph

Answer

Michael Desa picture Michael Desa · Jun 9, 2016

Assuming that you're dealing with a a counter, the query you're going to want is

SELECT derivative(max(requests))
FROM "nginx"
WHERE $timeFilter
GROUP BY time($interval)