Splunk Search

create table based on end time and time limit

Carolina
Engager

Hi,

i need to create a table with the following conditions:
This is my log:

proceso,start,end,diferencia,tiempo
PRUEBA02,19:10:00.00,01:00:00.00,05:10:00.00,22:50:00.10
PRUEBA03,01:00:00.00,03:00:00.00,02:00:00.00,04:00:00.00
PRUEBA04,22:00:00.00,00:00:00.00,03:00:00.00,23:00:00.00
PRUEBA05,18:00:00.00,04:00:00.00,10:00:00.00,22:30:00.00
PRUEBA06,21:00:00.00,02:00:00.00,05:00:00.00,01:00:00.00

I require to alert when the tiempo field is greater the end field.
The fields have a format of 24 hours.
In addition, some processes may end earlier than planned

I use the command where but but as a result it shows me the events that ended earlier and its limit is the next day.

source="pruebajob.csv" host="LAPTOP-3UME9D0Q" index="test"
| eval time1=strftime(strptime(tiempo,"%H:%M:%S.%2N"),"%H")
| eval time2=strftime(strptime(end,"%H:%M:%S.%2N"),"%H")
| eval time3=strftime(strptime(diferencia,"%H:%M:%S.%2N"),"%H")
| eval value=time1+time3
| eval compare=if(time1>time2,value,time3)
| where time1<compare

it is possible to create create a table?

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi Carolina,
you have to transform times in epochtime before comparing, something like this:

 source="pruebajob.csv" host="LAPTOP-3UME9D0Q" index="test"
| eval et_end=strptime(end,"%H:%M:%S.%2N"), et_tiempo=strptime(tiempo,"%H:%M:%S.%2N")
| where et_tiempo>et_end

Bye.
Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi Carolina,
you have to transform times in epochtime before comparing, something like this:

 source="pruebajob.csv" host="LAPTOP-3UME9D0Q" index="test"
| eval et_end=strptime(end,"%H:%M:%S.%2N"), et_tiempo=strptime(tiempo,"%H:%M:%S.%2N")
| where et_tiempo>et_end

Bye.
Giuseppe

0 Karma

Carolina
Engager

Thank you !

0 Karma

renjith_nair
Legend

From the above example for the process PRUEBA02, tiempo : 22:50:00.10 , end :01:00:00.00
How do you distinguish between current day or next day? Is this process completed before the limit which is 01 AM?

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

Carolina
Engager

It is correct this process ended before its limit.
Only the time distinguishes it

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...