0

I using Grafana and influxdb to collect ‘product data’ in the assembly line. I make a chat by grafana to show how many products was done in every hour. enter image description here It works good, but i have one problem, sometimes the worker will clear the total count because of shifts change. this cause the division data less than 0. enter image description here

Considering this serial data(each data 10 minutes):

100 200 300 400 0 10 20

the correct time divisional value in this hour should be (400-100) + (20-0) = 320

I tried also search but no help, do you have any ideas? (Sperate to 2 time divisions when data set to 0 is also OK , in this sample, we can get two bars with 300 and 20)

Thanks a lot!

Elan.Cao
  • 75
  • 10

1 Answers1

0

Use different approach with subqueries:

1.) Inner query will calculate diff between each record with NON_NEGATIVE_DIFFERENCE() -> 100 100 100 0 10 10

2.) Outer query will just SUM() result of inner query and group it per hour -> 320

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59