Splunk Search

how to use transaction command for event spanning multiple days

jassal
New Member

I'm trying to show the total HVAC usage during the day using transaction command:

name=thermostatoperatingstate | transaction device startswith=cooling endswith=idle | eval duration=round(duration/3600,1) | timechart span=1d sum(duration) as sum

However for transactions that span through midnight I'd like to split the "duration" at midnight so I can show how much the AC ran during a given day. In the command above if AC started at 8PM and stopped at 2AM, I'd like 4 hours usage to be listed for the given day and 2 hours usage to be listed against next day. With the command about I get 6 hours of AC usage for the given day.

Is there a way to day that?

0 Karma

jassal
New Member

This is how the raw data is logged in. Thx.

[02/Jul/2018:06:17:42 -0400] "GET /log.php?device=Nest-Up&name=thermostatOperatingState&value=idle
[01/Jul/2018:19:44:41 -0400] "GET /log.php?device=Nest-Up&name=thermostatOperatingState&value=cooling
[01/Jul/2018:18:56:41 -0400] "GET /log.php?device=Nest-Up&name=thermostatOperatingState&value=idle
[01/Jul/2018:18:32:42 -0400] "GET /log.php?device=Nest-Up&name=thermostatOperatingState&value=cooling

0 Karma

niketn
Legend

@jassal, can you please share couple of sample raw data for cooling and idle? We might need to create field extraction for action as cooling and idle so that we can use stats instead of transaction.

For your scenario you should be better off choosing stats over transaction command. Refer to my older answer: https://answers.splunk.com/answers/483152/is-the-transaction-command-suitable-for-large-volu-1.html

Also, Answers should have several posts on similar lines for converting transaction to stats. Following are couple such example, please adapt as per your need.

1) https://answers.splunk.com/answers/507469/will-using-the-join-and-transaction-commands-work.html
2) https://answers.splunk.com/answers/624143/how-to-make-a-transaction-using-same-id-that-has-e.html

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...

Global Splunk User Group Events: May + June 2026

Your Splunk Community Awaits: Discover Upcoming User Group Events Worldwide    Staying ahead in the fast-paced ...