So with my home automation I have a device that measures my house energy usage. It reports about every 30 seconds.
So I want to be able to figure out what my daily usage is and then be able to do it over the last 7 days and then monthly.
I was told for the daily to take the sum of all the values then divide it by the number of events. The number of events change daily because sometimes my meter stops reporting and then I have to wait for it to be reset which it does within in 5 mins.
So here is my cool search that shows me my current energy usage
index=main source=smart* device="Home Energy" | rename value AS EnergyUsageWatt | eval EnergyUsageKwh=EnergyUsageWatt/1000
Then I just take that and use a stats first at the end and run it in real time. So how can I take the value of EnergyUsageKwh and then add up all of the values of that for the day.
Also is there a way to count how many events that were returned and use that as a variable in the search string? Thank you all for your help with this.
Try like this
index=main source=smart* device="Home Energy" | eval Date=strftime(_time,"%Y/%m/%d") | stats sum(value) as EnergyUsageWatt count as NoOfEvents by Date | eval Usage=EnergyUsageWatt/1000/NoOfEvents | eval Date Usage
This is working if I drop this off the end of the search | eval Date Usage thank you so much for your help with this, this is awesome.