Splunk Search

time based search based on a table of time values

thrpa001
Loves-to-Learn Lots

I have a base search below but I need to use a time_window that is in table since various logs come in at diff times and I'm trying to create alerts for indexes not reporting but I dont want false positives for indexes that have a expected time lag.  splunk_security_index is used to get a specific subset of indexes.  

 

| tstats max(_time) as _time where index=* by index sourcetype | lookup splunk_security_indexes.csv index as index OUTPUT index time_window
| eval time_window="-7d@d" | where _time < relative_time(now(),'time_window')

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

How does that query fail to meet your needs? 

Why is time_window fetched from a lookup file and then hard-coded?

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

yuanliu
SplunkTrust
SplunkTrust

Why is time_window fetched from a lookup file and then hard-coded?

I think you just cracked the code why the original code did not deliver.

@thrpa001 wrote:

| tstats max(_time) as _time where index=* by index sourcetype | lookup splunk_security_indexes.csv index as index OUTPUT index time_window
| eval time_window="-7d@d" | where _time < relative_time(now(),'time_window')


I suspect the intention is

| tstats max(_time) as _time where index=* by index sourcetype
| lookup splunk_security_indexes.csv index as index OUTPUT index time_window
| where _time < relative_time(now(), time_window)

In other words, "time_window" should not have quotes surrounding it.

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...