Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating request per second using InfluxDB on Grafana

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

like image 313
jk2K Avatar asked Jun 04 '16 13:06

jk2K


People also ask

Can InfluxDB used with Grafana?

Use Grafana or Grafana Cloud to visualize data from your InfluxDB Cloud instance.

How do I view InfluxDB data in Grafana?

To access data source settings, hover your mouse over the Configuration (gear) icon, then click Data sources, and then click the data source. InfluxDB data source options differ depending on which query language you select: InfluxQL or Flux.

Should I use flux or InfluxQL?

InfluxDB v2. 5 is the latest stable version. Flux is an alternative to InfluxQL and other SQL-like query languages for querying and analyzing data. Flux uses functional language patterns making it incredibly powerful, flexible, and able to overcome many of the limitations of InfluxQL.

How do you query in InfluxDB?

To perform an InfluxQL query, send a GET request to the /query endpoint, set the URL parameter db as the target database, and set the URL parameter q as your query. You can also use a POST request by sending the same parameters either as URL parameters or as part of the body with application/x-www-form-urlencoded .


1 Answers

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)
like image 64
Michael Desa Avatar answered Oct 28 '22 13:10

Michael Desa