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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...