Query collectd data from influxDB


I have collectd sending time series data to influxdb, more specifically the disk plugin.

When I get data for a given time frame I can see that the values are incremental:

SELECT * FROM "disk_write" WHERE time > now() - 5m and type='disk_ops' and instance='sdb3';

So to get the actual value that will be used to draw a point in the final graph I would need to substract the previous value from the last value.


144771811 - 144771581 = 230

And I would need to do this for each interval in the given time frame.

Is there some special crafted query I can use so influxdb calculates and sends me automatically the substracted value from NEXT - PREVIOUS intervals?

I hope it makes sense.
Please help. THanks in advance

When working with counters like the one you describe, the non-negative derivative function is generally used to get the rate of change over a period of time.

1 Like

Thanks for your response it helped find what I need. I was able to get the data with the following in the end:

SELECT non_negative_derivative(
                last("value"), 10s) 
FROM "disk_read" 
        WHERE ("type" = 'disk_ops' AND "instance" = 'sda') 
                    AND time > now() - 12d 
GROUP BY time(10s) 
limit 20

However there’s another problem that I am facing. If some of the matched selections have a null value because for some reasons the data for that particular time entry did not get into influxdb then I end up with unpredictable results and all the results are messed up.

Is there any way to tell the query to ignore null valued results?