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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...