Splunk Search

How to search for values greater than 90 days?

willsy
Communicator

index=test sourcetype=csv source=prtg.csv host=prtg device=all "Down for"=*
| rename "Down for" AS Downtime
| eval "Downtime"=replace('Downtime',"d","")
| dedup _raw
| table Device, Downtime

Is there a way to only show any devices with a downtime greater than 90 in that table?

Labels (3)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @willsy,

let me understand do you have values like "54 d" or value in epochtime, or both?

if of the first type, you can use a regex like the following to extract days:

| rex "(?<downtime_days>\d*)\s+d"

if of the second type, you can use eval and divide for the number of seconds in a day:

| eval downtime_days=your_field/86400

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @willsy,

which is the time format of Downtime?

define the threshold in the same time unit and then use the where command to make a filter, 

so e.g. Downtime is expressed in days, you can use 

| where Downtime>90

if it's expressed in seconds, you can use:

| where Downtime>7776000

Ciao.

Giuseppe

0 Karma

willsy
Communicator

Also just to add,

When i add
| where Downtime>90

i get the error

Error in "where" command: Type checking failed. the '>' operator received different types

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @willsy,

see what you have in the Downtime field, maybe there are different formats values: e.g. sometime 10, and sometimes 10d.

identify the different choices and extract the numers using a regex.

If you share some samples containing all the choices, I could help you.

Ciao.

Giuseppe

0 Karma

willsy
Communicator

@gcusellothank you for getting back to me so fast,

i have various formats of,

54 d
125 d
12 h 2 m
4 d 4 d 29 m

I do have a raw value for the time though that i can use, that is under epoch times.

"Down for_RAW"
0000000016415216
0000000000141890
0000000000067157

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @willsy,

let me understand do you have values like "54 d" or value in epochtime, or both?

if of the first type, you can use a regex like the following to extract days:

| rex "(?<downtime_days>\d*)\s+d"

if of the second type, you can use eval and divide for the number of seconds in a day:

| eval downtime_days=your_field/86400

Ciao.

Giuseppe

willsy
Communicator

Absolute scholar and a gent.

thank you so very much.

i used the
| eval downtime_days=Downtime/86400

seems super simle now i can see it but i couldnt get my head round it, thanks you so very much.

0 Karma

willsy
Communicator

Hey @gcusello 

So thats what i originally had in my search however it only resulted in a single device with value of 96.

where as there are 9 devices with a higher than 90 value.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...