NeverSleeps
NeverSleeps

Reputation: 1948

Calculation average request time using InfluxDB on Grafana

I am using influx to save metrics. I am trying to create a dashboard in grafana that will show the average execution time of a method per hour.

This is my query for calculating execution time of a method:

enter image description here

raw sql: enter image description here

The query to calculate the average time.

SELECT MEAN("sum") FROM "autogen"."pfr_timed_http_request" 
WHERE "method"='request' AND $timeFilter 
GROUP BY time(1h) fill(null)

But if the execution time graph looks like the truth, then the average execution time graph looks strange. The average should be about 4s, but it is even much less than 1. Perhaps this is due to the fact that the calculation includes null as 0. Can they be excluded from the calculation? What am I doing wrong? ![enter image description here enter image description here

Upvotes: 1

Views: 2711

Answers (1)

Jan Garaj
Jan Garaj

Reputation: 28714

I guess sum field (not very intuitive field name) holds response time, so average response time calculation:

SELECT MEAN("sum")
FROM "autogen"."pfr_timed_http_request"
WHERE "method"='request'
  AND $timeFilter
GROUP BY time(1h) fill(null)

Upvotes: 1

Related Questions