<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic compute the macro name  to be used in a search in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407624#M26725</link>
    <description>&lt;P&gt;Hi Guys, &lt;BR /&gt;
Is it possible to calculate the name of a macro to be used in a search from a token value?&lt;/P&gt;

&lt;P&gt;I have a drop down list of system names that I have corresponding macros for.&lt;/P&gt;

&lt;P&gt;eg &lt;BR /&gt;
key = ABC  -  macro = ABC_hosts&lt;BR /&gt;
key = DEF  - macro = DEF_hosts&lt;BR /&gt;
key = GHI -  macro =  GHI_hosts&lt;/P&gt;

&lt;P&gt;When a user selects an item from the list I want to use the token in my search to compute which macro to use. Is there a way to compute the macro name in the search?&lt;/P&gt;

&lt;P&gt;$system$_host&lt;BR /&gt;
if the user selected ABC I would like the search to have the following calculated using the token&lt;BR /&gt;
 index="_main" &lt;CODE&gt;ABC_hosts&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:54:37 GMT</pubDate>
    <dc:creator>Melstrathdee</dc:creator>
    <dc:date>2020-09-29T20:54:37Z</dc:date>
    <item>
      <title>compute the macro name  to be used in a search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407624#M26725</link>
      <description>&lt;P&gt;Hi Guys, &lt;BR /&gt;
Is it possible to calculate the name of a macro to be used in a search from a token value?&lt;/P&gt;

&lt;P&gt;I have a drop down list of system names that I have corresponding macros for.&lt;/P&gt;

&lt;P&gt;eg &lt;BR /&gt;
key = ABC  -  macro = ABC_hosts&lt;BR /&gt;
key = DEF  - macro = DEF_hosts&lt;BR /&gt;
key = GHI -  macro =  GHI_hosts&lt;/P&gt;

&lt;P&gt;When a user selects an item from the list I want to use the token in my search to compute which macro to use. Is there a way to compute the macro name in the search?&lt;/P&gt;

&lt;P&gt;$system$_host&lt;BR /&gt;
if the user selected ABC I would like the search to have the following calculated using the token&lt;BR /&gt;
 index="_main" &lt;CODE&gt;ABC_hosts&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:54:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407624#M26725</guid>
      <dc:creator>Melstrathdee</dc:creator>
      <dc:date>2020-09-29T20:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: compute the macro name  to be used in a search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407625#M26726</link>
      <description>&lt;P&gt;Well, in theory tokens are replaced in a dashboard before the search runs, so this should work as long as &lt;CODE&gt;ABC_hosts&lt;/CODE&gt; uses the proper format of a macro &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;`ABC_hosts`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so, just try it and see if it works for you &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 03:50:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407625#M26726</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-08-14T03:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: compute the macro name  to be used in a search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407626#M26727</link>
      <description>&lt;P&gt;Thanks Mas for the response, I guess my problem is how to I turn the value to my token into a macro. &lt;/P&gt;

&lt;P&gt;I'm not sure of the syntax, how do I add the value of the token and _hosts and have splunk treat it as a macro?&lt;/P&gt;

&lt;P&gt;so it my token value is ABC I want to add _host to it an pop some quotes around it so it becomes  'ABC_hosts'&lt;/P&gt;

&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:55:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407626#M26727</guid>
      <dc:creator>Melstrathdee</dc:creator>
      <dc:date>2020-09-29T20:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: compute the macro name  to be used in a search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407627#M26728</link>
      <description>&lt;P&gt;@Melstrathdee there would be multiple ways to do this&lt;/P&gt;

&lt;P&gt;1) Code &lt;CODE&gt;&amp;lt;change&amp;gt;&lt;/CODE&gt; event handler for dropdown to set for macro to be replaced in search query&lt;BR /&gt;
2) Code &lt;CODE&gt;&amp;lt;change&amp;gt;&lt;/CODE&gt; event handler for dropdown to set complete search query with macro replaced selected value.&lt;BR /&gt;
3) Modify SPL to have macro call and actual macro value to be replaced with value selected in dropdown. (As pointed out my @MuS)&lt;/P&gt;

&lt;P&gt;You should be able to find examples of each on Splunk answers.&lt;/P&gt;

&lt;P&gt;If you can give sample SPL to be invoked for couple of dropdown values selected we would be able to assist you with specific option you want to implement.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 03:19:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407627#M26728</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-16T03:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: compute the macro name  to be used in a search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407628#M26729</link>
      <description>&lt;P&gt;Thanks guys I got it working using the following code:&lt;BR /&gt;
it basically puts the macros with thei name and code in a table and returns one column as the name and the the search string column as the field value.&lt;BR /&gt;
Thanks for the help&lt;BR /&gt;
    &lt;INPUT type="dropdown" token="system_filter" searchwhenchanged="false" /&gt;&lt;BR /&gt;
      &lt;FIELDFORLABEL&gt;sysName&lt;/FIELDFORLABEL&gt;&lt;BR /&gt;
      &lt;FIELDFORVALUE&gt;definition&lt;/FIELDFORVALUE&gt;&lt;BR /&gt;
     &lt;LABEL&gt;System&lt;/LABEL&gt;&lt;BR /&gt;&lt;BR /&gt;
           &lt;DEFAULT&gt;$sysName$&lt;/DEFAULT&gt;&lt;BR /&gt;
      &lt;SEARCH&gt;&lt;BR /&gt;
        &lt;QUERY&gt;| rest splunk_server=local /servicesNS/-/-/admin/macros | search  eai:acl.app="my_app" title="*hosts"&lt;BR /&gt;
| eval sysName =  substr(title, 1, len(title)-6)&lt;BR /&gt;
 | Table sysName, title, definition&lt;BR /&gt;
      &lt;/QUERY&gt;&lt;BR /&gt;
    &lt;/SEARCH&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:55:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/compute-the-macro-name-to-be-used-in-a-search/m-p/407628#M26729</guid>
      <dc:creator>Melstrathdee</dc:creator>
      <dc:date>2020-09-29T20:55:31Z</dc:date>
    </item>
  </channel>
</rss>

