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