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
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...