The time window is confusing when use group by time()

Hi, I encountered some problems during the process of using InfluxDB. Could you please help me solve it?

  • InfluxDB Version:
    1.8.5

  • InfluxQL:
    Firstly, I searched a batch of data using non_negative_derivative:

select non_negative_derivative(mean(value), 1s) as value from cpu where time>=1742784780s and time<=1742784900s and host='ServerG' group by "host","region",time(30s)

The returned data is as follows:

name: cpu
tags: host=ServerG, region=regionF
time                 value
----                 -----
2025-03-24T02:53:00Z 99.92713464696222
2025-03-24T02:53:30Z 52.82068965517244
2025-03-24T02:54:00Z 61.2817471264368
2025-03-24T02:54:30Z 67.2928888888889

Then, I use sum() to sum up the above results

select sum(value) from (select non_negative_derivative(mean(value)) as value from cpu where time>=1742784780s and time<=1742784900s and host='ServerG' group by "host","region",time(30s)) where time>=1742784780s and time<=1742784900s group by "region",time(30s)

The returned data is as follows:

name: cpu
tags: region=regionF
time                 sum
----                 ---
2025-03-24T02:53:00Z
2025-03-24T02:53:30Z 52.82068965517244
2025-03-24T02:54:00Z 61.2817471264368
2025-03-24T02:54:30Z 67.2928888888889
2025-03-24T02:55:00Z
  • Question
    I want to know why the first and last time windows in the second query result have no values?

If the timestamps in the subquery results (e.g., 02:53:00Z) don’t exactly align with the bucket start times in the outer query (due to slight internal rounding or float precision), the engine skips them. What precision are you writing with?

However if you want to sum all the values try:

SELECT sum(value) FROM (
    SELECT non_negative_derivative(mean(value)) AS value
    FROM cpu
    WHERE time >= 1742784780s AND time <= 1742784900s AND host='ServerG'
    GROUP BY "host", "region", time(30s)
)

As right now your sum isnt doing a lot