Scripted Field - Sum of Field values to then use as a Max?

Hi,
This use case is for an electricity monitoring system, where we have two sources of supply to a building (A&B). Each of these supplies are metered and in the elastic cloud. We have visualizations for the data, but we are are unsure of how to add up the raw-power values (kilowatts) of these two meters and then display as a max (so we know the peak kW for the site). Would this be done by a scripted field, and if so, could you please provide an example? i assume you will need both the meter identifier and unit of measure to calculate

Meter_Name: "MSB-1" and "MSB-2"
value_unit: kW

Hi @Dave21854207!

It might be helpful here to see what your data looks like, as well as an example of what you're trying to accomplish. Could you provide a couple of the documents?

Hi Lukas,
Thanks for the quick reply. Heres an example doc here (let me know if you need to see JSON) !

I have also included a heatmap visualization, which is set for a max. Because these values are power (instantaneous), we can't sum the values (were only interested in the highest recorded value for the interval and docs are ingested every 5mins).

The heatmap is divided into hour-of-day, so the highest value of the sum of two main meters is required. Currently, only the max of one meter is shown. Regarding the filters on the heatmap: Meter_Hierarchy: "Main Power" = MSB-1 and MSB-2 Grid or Solar Energy; NOT Meter_Service: "Solar Energy" = isolates only the Grid meters MSB-1 and MSB-2; kW is the power value.
heatmap

Hmm, so you want to sum the value for both MSB-1 and MSB-2 for each 5-minute interval, and then plot the maximum value over an interval (e.g. an hour)?

I don't think this will be very easy to accomplish without ingesting additional data. Scripted fields won't work because they operate on an individual document level.

If you have control over ingestion, could you ingest another doc each 5 mins with a value obtained from the sum of MSB-1 and MSB-2, which has a Meter_Name of something like MSB-1/MSB-2? Then it would make this sort of thing quite easy.

Yeah i didn't think it was that easy... All good, we will have to create a virtual meter.
Only disadvantage to this is we wont have access to historical data, which is why there is a benefit to being able to aggregate directly from the database.

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