Splunk Enterprise

Figure out my daily energy usage

thefuzz4
Path Finder

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.

Tags (1)
0 Karma

somesoni2
Revered Legend

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
0 Karma

thefuzz4
Path Finder

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.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...