<?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 Re: Macro expansion via SPL/REST in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/691215#M235394</link>
    <description>&lt;P&gt;You can give this a try&lt;BR /&gt;&lt;A href="https://github.com/dtburrows3/Splunk_Expand_Macros_Command" target="_blank"&gt;https://github.com/dtburrows3/Splunk_Expand_Macros_Command&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;A work in progress but seems to cover majority of things I have thrown at it so far.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jun 2024 21:31:01 GMT</pubDate>
    <dc:creator>dtburrows3</dc:creator>
    <dc:date>2024-06-20T21:31:01Z</dc:date>
    <item>
      <title>Macro expansion via SPL/REST</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/655050#M226288</link>
      <description>&lt;P&gt;I have a search that returns all of my correlation searches for a given app.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| rest splunk_server=local count=0 /services/saved/searches
| where match('action.correlationsearch.enabled', "1|[Tt]|[Tt][Rr][Uu][Ee]")
| rename eai:acl.app as app, title as csearch_name, action.correlationsearch.label as csearch_label, action.notable.param.security_domain as security_domain
| search app=my_app 
| table csearch_name, csearch_label, app, security_domain, qualifiedSearch, description

&lt;/LI-CODE&gt;
&lt;P&gt;This works fine and gives the desired output.&amp;nbsp; However, I would like to add a line in there that would automatically expand any macros in the qualifiedSearch field.&lt;/P&gt;
&lt;P&gt;e.g.&lt;/P&gt;
&lt;P&gt;search `azuread` "body.operationName"="Add member to role"&lt;/P&gt;
&lt;P&gt;but return:&amp;nbsp;&lt;BR /&gt;search sourcetype=mscs:azure:eventhub "body.operationName"="Add member to role"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a lookup or macroExpand function that I could add to my SPL to do this?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 23:12:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/655050#M226288</guid>
      <dc:creator>paulcurry</dc:creator>
      <dc:date>2024-06-20T23:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro expansion via SPL/REST</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/673581#M230648</link>
      <description>&lt;P&gt;I also was looking for something that did this for a really long time and could never find anything.&amp;nbsp;&lt;BR /&gt;I know about the CMD+SHIFT+E to expand macros on the UI but needed the same functionality inline in a search to use for meta-analysis (breaking down SPL to its components and analyzing).&lt;BR /&gt;&lt;BR /&gt;I feel like there is some way of doing this that exists somewhere but have not had much luck finding it.&amp;nbsp;&lt;BR /&gt;So went ahead and tried making a custom command to do it and it actually seems to work out pretty well.&lt;BR /&gt;I do want to note that this custom command is recursive in a sense that it expands the macros all the way down. Meaning that if there are nested macros that this will expand the nested ones as well all the way unil there are no more macros to expand. So end result should be a fully detailed SPL that is being executed. It will also replace the input args with the values it finds in the input field so it will also return that SPL that would run for that specific search with the given arguments.&lt;BR /&gt;You can see an example of the output here (this particular example is derived from a dashboard, so input arguments are still tokenized and will be represented as such in the "expanded_spl" field):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1704761420227.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28799i707276275DFBEF12/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1704761420227.png" alt="dtburrows3_0-1704761420227.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you are still interested in this than you can give this a try, I think it will require entries in a commands.conf, searchbnf.conf metadata/local.meta and a custom python script in bin/&lt;BR /&gt;&lt;BR /&gt;There is also a dependency on Splunk Python SDK.&lt;BR /&gt;&lt;BR /&gt;Send me a message and I can get it packed up in a custom app to share if you still are needing this functionality.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 01:23:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/673581#M230648</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-09T01:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro expansion via SPL/REST</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/690910#M235300</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/263242"&gt;@dtburrows3&lt;/a&gt;&amp;nbsp;Would you be able to share your code or a snippet of the relevant function calls? I am trying to create a similar expansion command but have not yet been able to locate the appropriate functions to use in the Splunk Python SDK.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 15:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/690910#M235300</guid>
      <dc:creator>johnhadfield</dc:creator>
      <dc:date>2024-06-17T15:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro expansion via SPL/REST</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/691215#M235394</link>
      <description>&lt;P&gt;You can give this a try&lt;BR /&gt;&lt;A href="https://github.com/dtburrows3/Splunk_Expand_Macros_Command" target="_blank"&gt;https://github.com/dtburrows3/Splunk_Expand_Macros_Command&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;A work in progress but seems to cover majority of things I have thrown at it so far.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 21:31:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Macro-expansion-via-SPL-REST/m-p/691215#M235394</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-06-20T21:31:01Z</dc:date>
    </item>
  </channel>
</rss>

