Splunk Search

What is this Where clause by time doing?

wrussell12
Explorer

Is this requesting all the records, from 3 minutes ago?

index="my_index" source="bandstats" recordType="core" 
    | dedup coreName 
    | where _time < (now() - 180) 

_time = 1565372570 (minus 3600)
now = 1565376170 (current time)
3mins ago = 1565375990
1565372570 < 1565375990

So, this search is looking for records that are older than 3 minutes ago?

This where clause seems to be making the entire search slow, what would be a better alternative?

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Yes, the where clause is looking for events that are at least 3 minutes old. This is unnecessary. Use index="my_index" source="bandstats" recordType="core" latest=-3m | dedup coreName.

You can confirm what is making the search slow with the Job Inspector.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Yes, the where clause is looking for events that are at least 3 minutes old. This is unnecessary. Use index="my_index" source="bandstats" recordType="core" latest=-3m | dedup coreName.

You can confirm what is making the search slow with the Job Inspector.

---
If this reply helps you, Karma would be appreciated.

wrussell12
Explorer

How could I use this what a datamodel, and tstats?

Optimized:

 index="my_index" source="bandstats" recordType="core" latest=-3m
     | dedup coreName 

.

 | tstats latest(band.coreName) as coreName from bandstats.band by coreId, _time
 | where _time < (now() - 180) 
0 Karma

richgalloway
SplunkTrust
SplunkTrust

tstats does not support the latest option so you're stuck with where.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...