Splunk Search

Calculate averages from 3rd Tuesday of Month to the 3rd Monday of following month

grhick
New Member

I am trying to create a table or timechart that tracks averages for an event from the 3rd Tuesday of every month to the 3rd Monday in the following month (on a reoccurring basis). For example I want the output to look like:

Time Range Average
1/17/12-2/20/12 14.8
2/21/12-3/19/12 15.3

Can someone please help me figure out how to write this query? Thank you for all of your help.

Tags (1)
0 Karma

lguinn2
Legend

Try this

yoursearchhere |
eval earliest=relative_time(now(),"-2mon@mon") |
eval earliest=relative_time(earliest,"+21d") |
eval earliest=relative_time(earliest, "@w2") |
eval latest = relative_time(earliest,"+28d") |
where _time >= earliest AND _time <= latest |
timechart avg(yourfield)

Good luck! BTW, you realize that if you run this each month, some days will get skipped. Also, you might want to change the second line from "-2mon@min" to "-1mon@mon", depending on when you run the search each month.

0 Karma

grhick
New Member

Thank you very much for the response. I will try this and let you know how it worked.

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...