Summing up maximum values per device per specific time


(Emil Mirzayev) #1

Hi! I have data with timestamp, device_id and value. I have around 1k devices which signal me their values. Value in t is always smaller or equal to the value in t+1. Which means, values are gradually increasing (in t if it was 1500, in t+1 it is 1503 and etc.). What I want to do, is to write a script which sums up maximum values per device_id per given time frame and then visualize it in timelion. How is this possible? My data structure is:
timestamp, device_id, ..(some not useful fields for this question).., value;
timestamp, another_device_id, .... , value;
timestamp+t, device_id, .... , value;
timestamp + t, another_device_id, .... , value;


(Mark Harwood) #2

Just wanting to size this query - are you saying you want 1000 data points for a single timeframe e.g "last week" or that you want multiple timeframes e.g. minute-level data points for the last 24 hours (=1000 x 24 x 60)


(Emil Mirzayev) #3

I want to sum up all data points (maximum consumptions of all devices) within the given frame. The thing is, I am interested in the latest value (which will be the maximum value) of each device summed up. For now, i have 1k devices, but they will probably increase in number soon. is it a way to do it dynamically? So that when i have 100k devices i don't have to re-edit the code again?


(Mark Harwood) #4

I still need the answer to the question about number of timeframes in the response. It determines whether this can be a single request.


(Emil Mirzayev) #5

Sorry for my misunderstanding. My time frame can be e.g last month, last 6 months, one year


(Mark Harwood) #6

That's the time range but I also need to know how many units that's divided into.
Perhaps put another way - how many lines of JSON do you think you'll need in a response?


(Emil Mirzayev) #7

One line per every timestamp. In other words, grouping by devices and timestamp and summing up maximum values, so that, for every timestamp field i will have the sum of all max values of all devices


(system) #8

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.