Dashboards & Visualizations

passing dropdown value as a macro with argument

nivethainspire_
Explorer

I created a dashboard with 5 dropdowns
I passed values of 4 dropdowns in the 5th.. the macro given in is working fine , but the macro given as value="" is not expanding.. can anyone help me with this
Here is my code..

<form>
<fieldset submitButton="false">
<input type="radio" token="val1" searchWhenChanged="true"></input>
<input type="radio" token="val2" searchWhenChanged="true"></input>
<input type="radio" token="val3" searchWhenChanged="true"></input>
<input type="radio" token="val4" searchWhenChanged="true"></input>
<input type="radio" token="val4" searchWhenChanged="true">
      <choice value="`macro1($val1$,$val2$,$val3$,$val4$)`">yes</choice> //not working
      <choice value="`macro2($val1$,$val2$,$val3$,$val4$)`">no</choice> //not working
       <default>`macro2($val1$,$val2$,$val3$,$val4$)`</default> //working
    </input>
       </fieldset>
       <row> 
      <table>
        <search>
          <query>$type$ ...</query></search></table></row>
</form>
Tags (3)
0 Karma

niketn
Legend

While your question seems to have truncated, macro will be accepting strings as argument, hence you should try to change to the following:

`macro1("$val1$","$val2$","$val3$","$val4$")`

`macro2("$val1$","$val2$","$val3$","$val4$")`

Please try out putting the tokens under double quotes when you pass to macro and it should work. Let us know if it does not.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

nivethainspire_
Explorer

Tried!!!... not working

0 Karma

niketn
Legend

Change the value for val4 radio to yes and no, based on corresponding selected choice.
Then code the change event to set the macro token callMacro which can be used in your search query. In your case value for choice is considering token as string hence not replacing its actual token value. Please try out the following code and let us know. (PS two of your inputs were val4. I have converted one to val5).

<fieldset submitButton="false">
    <input type="radio" token="val1" searchWhenChanged="true"></input>
    <input type="radio" token="val2" searchWhenChanged="true"></input>
    <input type="radio" token="val3" searchWhenChanged="true"></input>
    <input type="radio" token="val4" searchWhenChanged="true"></input>
    <input type="radio" token="val5" searchWhenChanged="true">
       <choice value="yes">yes</choice> //not working
       <choice value="no">no</choice> //not working
        <default>no</default> //working
        <change>
              <condition value="yes">
                  <set token="callMacro">`macro1("$val1$","$val2$","$val3$","$val4$")`</set>
              </condition>
              <!-- Else or default condition, will be hit when choice is No-->
              <condition>
                  <set token="callMacro">`macro2("$val1$","$val2$","$val3$","$val4$")`</set>
              </condition>
        </change>
     </input>
</fieldset>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

nivethainspire_
Explorer

I get the output,but not the expected result

0 Karma

niketn
Legend

@niventhainspire_07, You have used just the code for val5 right?
I would say that the code should work, if there is an issue with macro you would need to fix yourself or provide the details of macro here.

If you want to test whether the tokens for val1...val4 are being set up properly, you can use the following

     <change>
           <set token="callMacro">val1:$val1$, val2:$val2$, val3:$val3$, val4:$val4$</set>
     </change>
   </input>
</fieldset>
<row>
    <panel>
        <title>$callMacro$</title>
    </panel>
</row>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...