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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI! Discover how Splunk’s agentic AI ...

[Puzzles] Solve, Learn, Repeat: Dereferencing XML to Fixed-length events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...