Splunk Search

How do I group events that are less than 15 seconds apart?

brook8128
Engager

| transaction uno, programId, devicetype maxpause=15s
| eval s_time=_time | eval e_time=_time+duration
| eval watch_sec = e_time - s_time
| eval _time=s_time
| eval s_time = strftime(s_time, "%Y-%m-%d %H:%M:%S")
| eval e_time = strftime(e_time, "%Y-%m-%d %H:%M:%S")

alt text

| transaction uno, programId, devicetype
| eval s_time=_time | eval e_time=_time+duration
| eval watch_sec = e_time - s_time
| eval _time=s_time
| eval s_time = strftime(s_time, "%Y-%m-%d %H:%M:%S")
| eval e_time = strftime(e_time, "%Y-%m-%d %H:%M:%S")

alt text

When I use maxpause, events(00:00:00~00:06:50) are dropped.
I've changed it for 20 seconds, and then events(00:00:00~00:09:00) are dropped.

If there's any other way not to drop events, I want you to let me know.
Thx.

edit) I want to find time to use the program by user. There are about 400 million events a day, so I'm working on reducing these to about a million. I edited spl. Thx.

edit) My goal is
before)
00:00:00 ~ 00:59:57
01:00:03 ~ 01:59:58
02:00:02 ~ 02:30:00
04:30:00 ~ 04:59:56
05:00:01 ~ 05:30:00
21:30:00 ~ 21:59:55
22:00:04 ~ 22:30:00

after)
00:00:00 ~ 02:30:00
04:30:00 ~ 05:30:00
21:30:00 ~ 22:30:00

Tags (2)
0 Karma
1 Solution

woodcock
Esteemed Legend

DO NOT USE transaction! Try this:

index=<You should always specify an index> AND sourcetype=<And sourcetype too>
| streamstats current=f last(_time) AS next_time BY uno, programId, devicetype
| eval pause = next_time - _time
| streamstats count(eval(pause>15)) AS sessionID BY uno, programId, devicetype
| stats range(_time) AS duration list(_raw) AS _raw list(_time) AS time BY sessionID, uno, programId, devicetype

View solution in original post

woodcock
Esteemed Legend

DO NOT USE transaction! Try this:

index=<You should always specify an index> AND sourcetype=<And sourcetype too>
| streamstats current=f last(_time) AS next_time BY uno, programId, devicetype
| eval pause = next_time - _time
| streamstats count(eval(pause>15)) AS sessionID BY uno, programId, devicetype
| stats range(_time) AS duration list(_raw) AS _raw list(_time) AS time BY sessionID, uno, programId, devicetype

brook8128
Engager

It works!!!
Thank you for your answering!!!!

niketn
Legend

@brook8128 please add more details for the community to assist you better. What is the data you are trying to correlate? what does your current SPL look like?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...