influxdata / influxdb

Scalable datastore for metrics, events, and real-time analytics
https://influxdata.com
Apache License 2.0
28.64k stars 3.54k forks source link

Mean results strange when raw values change to 0 and "fill(previous)" #9671

Closed Apollon77 closed 5 years ago

Apollon77 commented 6 years ago

Bug report

System info: [Include InfluxDB version, operating system name, and other relevant details]

Steps to reproduce:

I experienced a strange behaviour when visualizing data that I collect from my solar/photovoltaic panels. I only log data when they change their value or if unchanged after 30minutes, Then I use "mean" to visualize them.

Example Data: See attchements:

What I experience is the following: The value changes to 0 (e.g. 1522596829232000000).

So I would expect that the "mean" of all 1m intervals after this timepoint is also 0.

What you can see in the selection result is: Query: SELECT mean("value") FROM "modbus.0.inputRegisters.30775_PV_Leistung" WHERE ("value" < 4000 AND "value" > -4000) AND time >= now() - 32h GROUP BY time(1m) fill(previous)

1522596780000000000 -134
1522596840000000000 -134
1522596900000000000 -134
1522596960000000000 -134
1522597020000000000 -134

And then it stays at this value of -134, but I would clearly expect a "mean" of 0 beginning with 1522596840000000000 .

Then at 1522598629238000000 a second "0" is written as data and with this it changes immediately in the result:

1522598520000000000 -134
1522598580000000000 0
1522598640000000000 0

... but way too late.

samaust commented 5 years ago

I don't see any bug. It works perfectly fine. Here's your data with the timestamps converted to a readable format.

1522596065285000000 | 2018-04-01 15:21:05,285 | 0 1522596803190000000 | 2018-04-01 15:33:23,190 | -90 1522596805606000000 | 2018-04-01 15:33:25,606 | -320 1522596813428000000 | 2018-04-01 15:33:33,428 | -180 1522596821376000000 | 2018-04-01 15:33:41,376 | -80 1522596829232000000 | 2018-04-01 15:33:49,232 | 0 1522598629238000000 | 2018-04-01 16:03:49,238 | 0

2018-04-01 15:33 contains the values -90, -320, -180, -80 and 0. The average of those is -134. The minutes after 15:33 don't contain any data until 16:03 so they get filled with -134.

tecmatia-dp commented 5 years ago

I have same problem. I think is a "bug" or a very big "concept mistake" for a TSDB. If last sample is "0", or any other value, and in next intervals are no data, the mean, min, max,...for next intervals should be calculated with last known sample, and not filled with last calculated value for a previous interval... When you log data with value change despite of regular time, last known value should be propagated to next intevals. I never undertand this behaviour of InfluxDB, is very fustrating to see this "bug" since years.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This issue has been automatically closed because it has not had recent activity. Please reopen if this issue is still important to you. Thank you for your contributions.