Splunk Search

How do you dynamically generate month name based on a search?

rwarnerii
New Member

I have created a Month over Month dashboard that will eventually become a report that is sent on the 1st day of the month, every month. Is it possible to dynamically generate the month name from the search? Assuming this is run on March 1st, my search contains the following for the time frames:

Previous Month (January) -  earliest=-2month@month latest=-1month@month
Current Month (February) - earliest=-1month@month latest=@month

How can I use these, or some other command, to generate the month names to use as column headers?

I'm currently using: "stats count as January" and "stats count as February" in the search, but I would like to remove those, so I don't have to edit the search for the proper month names each month.

Let me know if you need more information.

Thanks!

Rk.

0 Karma

woodcock
Esteemed Legend

Like this:

... | stats count AS [| makeresults | eval month=strftime(relative_time(now(), "@m"), "%B") | return $month ]

You may need to change @m to -1m@m.

0 Karma

mayurr98
Super Champion

hello

use this for every search:

index=<your_index> earliest=-2month@month latest=-1month@month date_month=* 
| stats count by date_month 
| transpose header_field=date_month 
| fields - column

this is common :

| stats count by date_month 
| transpose header_field=date_month 
| fields - column

let me know if this helps!

0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...