Splunk Search

How to pass eval value as macro parameter where my search query starts with macro itself

sainadh1247
New Member

We have created reusable macro which was used in many reports with 3 parameters and that macro is starting point of query. one parameter takes Month (i.e 02/01/2017 ...) from filter. Now i got requirement where i need to provide current month/previous month to macro as parameter . Since query begins with macro i unable to create eval expression .

query:

|eval month = strftime(now(),"%m/01/%Y") | 'ADForecast("$Domain$,month)'

since ,we cannot start a query with eval i unable to pass current month. please suggest how to pass current month.

0 Karma

ldongradi_splun
Splunk Employee
Splunk Employee

You can either start the search with :
search | ...
or use

| makeresults | ...

0 Karma

somesoni2
Revered Legend

Try like this. Assuming you're going to put this query in a dashboard (based on $Domain$ token used), put below query in the panel

|gentimes start=-1 | eval month=strftime(now(),"%m/01/%Y") | map search=" 'ADForecast("$Domain$,$$month$$)'
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...