Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate by time #4

Open
heubeck opened this issue Dec 9, 2022 · 2 comments
Open

Aggregate by time #4

heubeck opened this issue Dec 9, 2022 · 2 comments

Comments

@heubeck
Copy link
Owner

heubeck commented Dec 9, 2022

Especially with MySQL and similar backends the provided data might be too much.
A configurable value to report aggregated values (like average over 5 minutes) less frequent would be great.
Avg must not be senseful for every measurement, 'last' is more appropriate for e.g. a counter.

@seehase
Copy link
Contributor

seehase commented Dec 11, 2022

Aggregation period should be configurable e.g. in minutes

If there is an aggregation please provide additional information
for "counters" like ident 1.8.0
time, powermeterid, ident, value, unit, avg, max, min
e.g.
avg is calculated (counter_new - counter_old) / interval

                                       (38075)
time               ;   id     ident;   ;val  ;   unit  ;avg     ;max     ;min     ;unit
11.07.2018 15:30:00;   IDxyz  1.8.0    ;38085;   kWh;   2,000;   3,134;   1,234;   kW   
11.07.2018 15:35:00;   IDxyz  1.8.0    ;38093;   kWh;   1,600;   1,808;   0,934;   kW
11.07.2018 15:40:00;   IDxyz  1.8.0    ;38107;   kWh;   2,880;   3,432;   2,456;   kW
11.07.2018 15:45:00;   IDxyz  1.8.0    ;38125;   kWh;   3,600;   5,234;   1,345;   kW
                           

@seehausen
Copy link

seehausen commented Dec 26, 2022

I think as long as we use influxDB, aggregation is not needed
A better approach could be influx downsampling to store reduce historical data in a second bucket
and use union(tables: [power0, power0_downsampled]) to show all data in a single graph

https://www.influxdata.com/blog/downsampling-influxdb-v2-0/

sample query:

power0 = from(bucket: "power0")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "power")
  |> filter(fn: (r) => r["ident"] == "15.7.0")

power0_downsampled = from(bucket: "power0_downsampled")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "power")
  |> filter(fn: (r) => r["ident"] == "15.7.0")

union(tables: [power0, power0_downsampled])
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "last")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants