1

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

NeverSleeps
  • 1,439
  • 1
  • 11
  • 39

1 Answers1

1

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)
Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • Thanks you! The graph has become more truthful, but the average is still calculated very small. I have updated my question, please see – NeverSleeps Nov 24 '20 at 21:38
  • @NeverSleeps I would say that raw records query is wrong. Why you need SUM aggregation there? Why not simple `SELECT "sum" FROM "autogen"."pfr_timed_http_request" WHERE "method"='request' AND $timeFilter`. There can be a millions of requests with 1 ms response time, which are shown as X seconds response time with SUM aggregation. Don't blame graph, use table and list raw records/aggregated metrics there to prove records count/values/aggregations. – Jan Garaj Nov 24 '20 at 22:01