Getting Data In

Find Transactions that overlap a certain timestamp

Splunkster45
Communicator

I've been able to use the transaction command to group logins and logouts of users. What's the best way to find the transactions that occur overlap a certain timestamp? For example if I have a transaction that starts at 10 and ends at 11:00 I would want them to show up when searching 10:30.

I've been able to split the transaction up into two rows with data of the following form:
_time.........................................user....Login....Logout
12/29/14 10:00:00.000 AM..........A.........1............0......
12/29/14 11:00:00.000 AM..........A.........0............1......

and I think this form may be slightly easier to work with, but I can't think of how to grab all users that logged in before 10:30 and logged out after 10:30.

Thanks in advance!

Tags (2)
1 Solution

aweitzman
Motivator

All of your transactions will have a _time field representing the first event in the transaction, as well as a duration field telling you the difference in seconds between the first event in the transaction and the last event. Based on this, you can pass in the time you want and see whether it fits within that information.

...transaction-generating-search...
| convert num(_time) as startetime
| eval endetime=startetime+duration
| eval mytime="2015-01-07 12:34:56"
| convert timeformat="%Y-%m-%d %H:%M:%S" mktime(mytime) as myetime
| where myetime>=startetime and myetime<=endetime

Hope this is helpful.

View solution in original post

aweitzman
Motivator

All of your transactions will have a _time field representing the first event in the transaction, as well as a duration field telling you the difference in seconds between the first event in the transaction and the last event. Based on this, you can pass in the time you want and see whether it fits within that information.

...transaction-generating-search...
| convert num(_time) as startetime
| eval endetime=startetime+duration
| eval mytime="2015-01-07 12:34:56"
| convert timeformat="%Y-%m-%d %H:%M:%S" mktime(mytime) as myetime
| where myetime>=startetime and myetime<=endetime

Hope this is helpful.

Splunkster45
Communicator

Thanks! I ended up using | eval startetime=_time instead of | convert num(_time) as startetime but it worked for me!

0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...