Splunk Search

## How do you display the last 4 months in Splunk starting from the current month?

Path Finder

How do you display the last 4 months in Splunk starting from the current month?

Required output is:

January 2019
December 2018
November 2018
October 2018

Tags (1)
1 Solution
Legend

@sbhatnagar88 ,

Try

`````` |makeresults
|eval months=strftime(mvrange(relative_time(_time,"-3mon@mon"),relative_time(_time,"@mon+1"),"1mon"),"%B %Y")
|mvexpand months
``````

Detailed/expanded version

``````|makeresults
|eval earliest=relative_time(_time,"-3mon@mon")
|eval latest=relative_time(_time,"@mon+1")
|eval months=mvrange(earliest,latest,"1mon")
|eval months=strftime(months,"%B %Y")
|mvexpand months|table months
``````
---
What goes around comes around. If it helps, hit it with Karma 🙂
Communicator

I believe you need to change the maximum amount of results your query can display before you can do this. Unless you're talking about the actual syntax query.

Are you talking about the query or about not being able to see 4 months of data?

Legend

@sbhatnagar88 ,

Try

`````` |makeresults
|eval months=strftime(mvrange(relative_time(_time,"-3mon@mon"),relative_time(_time,"@mon+1"),"1mon"),"%B %Y")
|mvexpand months
``````

Detailed/expanded version

``````|makeresults
|eval earliest=relative_time(_time,"-3mon@mon")
|eval latest=relative_time(_time,"@mon+1")
|eval months=mvrange(earliest,latest,"1mon")
|eval months=strftime(months,"%B %Y")
|mvexpand months|table months
``````
---
What goes around comes around. If it helps, hit it with Karma 🙂
Path Finder

Great!! that works absolutely fine...thanks for help!!!

Legend

---
What goes around comes around. If it helps, hit it with Karma 🙂
SplunkTrust

---
If this reply helps you, Karma would be appreciated.
Path Finder

Thanks much!! Problem has been solved...

Get Updates on the Splunk Community!

#### 2024 Splunk Career Impact Survey | Earn a \$20 gift card for participating!

Hear ye, hear ye! The time has come again for Splunk's annual Career Impact Survey!  We need your help by ...

#### Optimize Cloud Monitoring

TECH TALKS Optimize Cloud Monitoring Tuesday, August 13, 2024  |  11:00AM–12:00PM PST   Register to ...

#### What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...