Hi, I have a table of time, machine, and total errors. I need to count for each machine how many times 3 errors (or more) happened in 5 min. if in one bucket more than 3 error happened I sign this row as True. finally i will return the frequency of 3 errors in 5 min (Summarize all rows==True) i succeeded in doing that in Python, but not in Splunk.
i wrote the following code :
| table TimeStamp,machine,totalErrors
| eval time = strptime(TimeStamp, "%Y-%m-%d %H:%M:%S.%3N")
| eval threshold=3
| eval time_window="5m"
| bucket span=5m time
| sort 0 machine,time
| streamstats sum(totalErrors) as cumulative_errors by machine,time
| eval Occurrence = if(cumulative_errors >= 3, "True", "False")
| table machine,TimeStamp,Occurrence
It almost correct. row 5 supposed to be True. If we calculate the delta time between row 1 to 5 more than 5 min passed, but if we calculate the delta time between row 2 to 5 less than 5 min passed and number of errors >=3 errors. How to change it so it will find the delta time between each row (2 to 5 , 3 to 5,.. ) for each machine ? hope you understand. i need short and simple code because i will need to do that also for 1m,2m,.. 3,5,..errors
row
Machine
TimeStamp
Occurrence
1
machine1
12/14/2023 10:12:32
FALSE
2
machine1
12/14/2023 10:12:50
FALSE
3
machine1
12/14/2023 10:13:06
TRUE
4
machine1
12/14/2023 10:13:24
TRUE
5
machine1
12/14/2023 10:17:34
FALSE
6
machine1
12/16/2023 21:01:45
FALSE
7
machine2
12/18/2023 7:53:54
False
thanks,
Maayan
... View more