I am currently building a Monitoring Application with the help of InfluxDB and Grafana and have come to an issue I couldn't find any solution to. Specifically, I am monitoring the Network Traffic of my Server in rate/s but since my the data source from where I get the Statistics only updates every 3-4 seconds, I have chosen to pick 5s. And right now I am just dividing the latest point by 5s to get the average per second. This is Problematic since if for some reason there is an downtime for 60 seconds, it will only be divided by 5..
First of all here my current query:
from(bucket: "Server")
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) => r._measurement == "interface" and (r._field == "rx_in") )
|> map(fn: (r) => ({r with _value: (r._value / 5) * 8}))
|> difference()
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
I've tried to create a second query lastPoint = from()
and then subtract _time in unix format to get the difference. But that resulted in type errors such as cannot convert stream to int