Splunk Enterprise

How to calculate Total Downtime &Uptime duration for Nodes?

udaypulipaka
Observer

Hi,I have one query that we need to submit node downtime duration report based on node monthly.Every month how much time that node down and how much time it is up.Please help me with the query.Please find the sample log(100 is up ,200 is down)

08/29/2022 10:05:00 +0000,host="0.0.1.1:NodeUp",alert_value="100"             

08/29/2022 10:05:00 +0000,host="0.1.1.1:NodeUp",alert_value="100"

08/29/2022 10:00:00 +0000,host="0.0.1.1:NodeDown",alert_value="200"

08/23/2022 10:10:00 +0000,host="0.0.1.1:NodeUp",alert_value="100" 

08/23/2022 09:55:00 +0000,host="0.0.1.1:NodeDown",alert_value="200"

Example:If node down for 30 min overall in a month different dates.still we need to display hostname along with dowtime(i.e 30min) and remaining uptime duration in one row

Note:Every 5min our Saved search will run and show this log data like above so that time stamp is will be every 5min

Labels (1)
0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

you could try something like this

| makeresults 
| eval _raw = "time,host,alert_value,status
08/29/2022 10:20:00 +0000,Node2,100
08/29/2022 10:05:00 +0000,Node1,100
08/29/2022 10:05:00 +0000,Node2,200
08/29/2022 10:00:00 +0000,Node1,200
08/23/2022 10:10:00 +0000,Node1,100
08/23/2022 09:55:00 +0000,Node1,200
| multikv forceheader=1
| eval _time = strptime(time, "%m/%d/%Y %H:%M:%S %z")
```prepare samples, real code is in next lines```
| sort 0 - _time
| transaction startswith=(alert_value="200") endswith=(alert_value="100") host
| stats sum(duration) as duration by host
| eval downtime = tostring(duration, "duration")

 If when there are "open status" within your period (like down, but not up or it's down before period and bring up on period), you must cover somehow.

r. Ismo

0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...