Hello Everyone,
I want to calculate the downtime for a particular server based on the difference between two EventCode which are Windows Event Logs.
Description of EventCode Below:
EventCode 1074: This EventCode is generated when the user tries to shutdown the server remotely.
EventCode 6013: This EventCode is generated when the server starts after successful reboot. Also this EventCode is generated on a daily basis at 12 AM which calculates the Server uptime in seconds.
Below is the sample sequence in which the log is pushed to splunk.
Scenario 1:
Sl No. Time EventCode
1 5/7/19 0:00 6013
2 5/7/19 10:05 6013
3 5/7/19 10:00 1074
4 5/7/19 0:00 6013
5 5/6/19 0:00 6013
6 5/5/19 0:00 6013
In the above case the user tried to reboot the server remotely which generated 1074 EventCode and after 5mins the server rebooted properly and EventCode 6013 generated. So using the transaction command we can find the duration of the downtime easily in this case.
Scenario 2:
Sl No. Time EventCode
1 5/7/19 0:00 6013
2 5/7/19 10:05 6013
3 5/7/19 10:00 1074
4 5/7/19 9:00 1074
5 5/7/19 0:00 6013
6 5/6/19 0:00 6013
7 5/5/19 0:00 6013
In this case user tried to reboot the server remotely at 9AM, but it didn't happen properly so user again tried to reboot the server at 10 AM. So in this case EventCode 1074 occured 2 times.
When I'm using the transaction commant in this case. It is grouping Sl No 4 and Sl No 2 AND it is also grouping Sl No 3 and Sl No 1, which should not be the case.
My requirement is it should take the first occurrence of EventCode 1074 and after that first occurrence of EventCode 6013 to calculate the proper downtime.. In the above case it should be Sl No 4 and Sl No 2.
Please fine the query I'm using for your reference:
index =abc sourcetype="WinEventLog:System"
|transaction host startswith="1074" endswith="6013"
|eval DurationMin = round(duration/60,2)
|stats list(_time) as Date list(DurationMin) as Dur_Min by host, DurationMin
|stats sum(DurationMin) as Total_Downtime_Duration_Min list(Date) as Downtime_Date list(Dur_Min) as Downtime_Min by host
|convert timeformat="%Y-%b-%d" ctime(Downtime_Date)
|rename host as Server_Name
|table Server_Name, Downtime_Date, Downtime_Min, Total_Downtime_Duration_Min
Appreciate your patience and response.
... View more