Splunk Search

Time duration filter

jerinvarghese
Communicator

Hi All,

 

Need help in getting the data for those Downtime > 15 mins. below is the query am using.

 

 

index=opennms "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
| fieldformat Time=strftime(Time,"%Y-%m-%d %l:%M:%S %p")
| sort- Time
| eval Downtime = tostring(now() - Time, "duration")
| rex field=Downtime "(?P<Downtime>[^.]+)"
| table Hostname Status Classification "Site Code", sitename, Time Downtime

 

 

 

output: 

Device nameDownBronzeLHCLuanda2020-08-05 2:02:40 PM00:14:45

 

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

OK.  I thought that might be the case, but it wasn't stated.

The clauses you tried won't work because they're comparing strings to integers.  You must compare numbers to numbers.

index=opennms "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
| fieldformat Time=strftime(Time,"%Y-%m-%d %l:%M:%S %p")
| sort- Time
| eval Downtime = now() - Time
| where Downtime > 900
| fieldformat Downtime = tostring(Downtime, "duration")
| rex field=Downtime "(?P<Downtime>[^.]+)"
| table Hostname Status Classification "Site Code", sitename, Time Downtime
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust
You have a search and you have results. What is the problem?
---
If this reply helps you, Karma would be appreciated.
0 Karma

jerinvarghese
Communicator

HI Rich, the data is for everything that appears in my tool. But i want a hold down timer of 15 mins.

i tried using below commands but that didn't worked.


| where Downtime >900

Also tried below

| where duration>900

 

but am not getting a data while adding this query. 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

OK.  I thought that might be the case, but it wasn't stated.

The clauses you tried won't work because they're comparing strings to integers.  You must compare numbers to numbers.

index=opennms "uei.opennms.org/nodes/nodeUp" OR "uei.opennms.org/nodes/nodeDown"
| fieldformat Time=strftime(Time,"%Y-%m-%d %l:%M:%S %p")
| sort- Time
| eval Downtime = now() - Time
| where Downtime > 900
| fieldformat Downtime = tostring(Downtime, "duration")
| rex field=Downtime "(?P<Downtime>[^.]+)"
| table Hostname Status Classification "Site Code", sitename, Time Downtime
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

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 ...