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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...