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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...