Splunk Search

How to create n strings for n months?

nick405060
Motivator

I need to create monthly filenames (2018-06-01.csv, 2018-07-01.csv, etc.) for n months. I can do something similar by day with n=30:

| makeresults | eval count=mvrange(0,30,1) | mvexpand count | eval filename=strftime(now()-count\*86400

How do I do this by month, something similar to the below syntax?

| makeresults | eval count=mvrange(0,12,1) | mvexpand count | eval filename=strftime(relative_time(now(), count \* "-1mon")
1 Solution

nick405060
Motivator

Turns out it was pretty easy:

| makeresults | eval count=mvrange(0,12,1) | mvexpand count | eval modifier="-"+tostring(count)+"mon" | eval filename=strftime(relative_time(now(),modifier),"%Y-%m-%d.csv")

View solution in original post

nick405060
Motivator

Turns out it was pretty easy:

| makeresults | eval count=mvrange(0,12,1) | mvexpand count | eval modifier="-"+tostring(count)+"mon" | eval filename=strftime(relative_time(now(),modifier),"%Y-%m-%d.csv")

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...