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!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...