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!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...