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!

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...

Auto-Injector for Everything Else: Making OpenTelemetry Truly Universal

You might have seen Splunk’s recent announcement about donating the OpenTelemetry Injector to the ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...