Splunk Search

How to count matching events in lookup in last 30 days?

Sven1
Path Finder

A have a lookup table that includes a "time" column (timeformat=%m/%d/%Y %H:%M:%S). Can someone please help me develop a search that counts the number of dates within that column that are within the last 30 days?

Thank you in advance. 

Sven

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Sorry, I missed out a minus

| inputlookup append=T lookup_march
| where time > relative_time(now(),"-30d")
| stats count as total

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You need to parse the time field into an epoch time with strptime(); you can then use the epoch time for comparisons and calculations

| eval epochtime=strptime(time,"%m/%d/%Y %H:%M:%S")
| where epochtime > relative_time(now(),"30d")

Sven1
Path Finder

ITWhisperer - Thank you!  

Can you please tell me also how I can do the same search, except the "time" column fields are in epoch time?  In other words, how would I revise the below search?

| inputlookup append=T lookup_march
| where time > relative_time(now(),"30d")
| stats count as total

  

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Sorry, I missed out a minus

| inputlookup append=T lookup_march
| where time > relative_time(now(),"-30d")
| stats count as total
0 Karma

Sven1
Path Finder

Thank you ITWhisperer.  I noticed that it might just need a minus sign, but did fully pursue. 

I appreciate your help. 

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

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...