Hey all, I’m having some trouble charting some data, and it looks like InfluxQL may not be able to do what I need. That is, do some math using the time difference between two rows. So I’m hoping that Grafana can do the work with a transformation?
Here’s my sample data:
| measurement | field | value | time |
|---|---|---|---|
| foo | evts | 349 | 2026-02-02 20:16:13 |
| foo | evts | 197 | 2026-02-02 20:16:47 |
| foo | evts | 471 | 2026-02-02 20:17:09 |
| foo | evts | 127 | 2026-02-02 20:17:23 |
| foo | evts | 426 | 2026-02-02 20:17:51 |
| foo | evts | 229 | 2026-02-02 20:18:19 |
The value is the number of events that have happened since the previous row of data. The time between rows is random. What I’m trying to get out is the rate of events:
| value | time |
|---|---|
| - | 2026-02-02 20:16:13 |
| 5.8 | 2026-02-02 20:16:47 |
| 21.4 | 2026-02-02 20:17:09 |
| 9.1 | 2026-02-02 20:17:23 |
| 15.2 | 2026-02-02 20:17:51 |
| 8.2 | 2026-02-02 20:18:19 |
So the first value is skipped (because there’s no previous record to compare with), the second value shows 5.8 events per second (197 events in 34 seconds), etc.
Any suggestions?
In case it matters, I’m using Grafana 10.2.6 with an InfluxQL data source talking to InfluxDB 2.8.0. This is my current query, but obviously is not what I want:
SELECT mean("evts")
FROM "foo" WHERE ("host"::tag = '$server') AND $timeFilter
GROUP BY time($__interval) fill(null)