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 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...