<?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 Is there an SPL command using REST to list the macros contained within a macro? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289822#M55302</link>
    <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello, I see that we can use SPL to get a list of arguments, "args", of a macro using the "rest" command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rest /services/configs/conf-macros
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt; It would be great to be able to list all the dependencies of a macro.&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt; In particular, is there a way to use the "rest" command to get a list of &lt;STRONG&gt;macros depended upon&lt;/STRONG&gt; by another macro?&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt; For instance, is it possible to get the following output? (See the third column "macros_called_by_macro".)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|---- args ----|---- title ----|---- macros_called_by_macro ---| --- author --- | --- definition --- |
|              |     macro_01  |    macro_02, macro_03         |
|              |     macro_02  |    macro_04                   |
|              |     macro_03  |                               |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks so much!!!&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 17:30:10 GMT</pubDate>
    <dc:creator>kdwsplunk</dc:creator>
    <dc:date>2020-09-29T17:30:10Z</dc:date>
    <item>
      <title>Is there an SPL command using REST to list the macros contained within a macro?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289822#M55302</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello, I see that we can use SPL to get a list of arguments, "args", of a macro using the "rest" command.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rest /services/configs/conf-macros
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt; It would be great to be able to list all the dependencies of a macro.&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt; In particular, is there a way to use the "rest" command to get a list of &lt;STRONG&gt;macros depended upon&lt;/STRONG&gt; by another macro?&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt; For instance, is it possible to get the following output? (See the third column "macros_called_by_macro".)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|---- args ----|---- title ----|---- macros_called_by_macro ---| --- author --- | --- definition --- |
|              |     macro_01  |    macro_02, macro_03         |
|              |     macro_02  |    macro_04                   |
|              |     macro_03  |                               |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks so much!!!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:30:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289822#M55302</guid>
      <dc:creator>kdwsplunk</dc:creator>
      <dc:date>2020-09-29T17:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an SPL command using REST to list the macros contained within a macro?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289823#M55303</link>
      <description>&lt;P&gt;Try this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rest /services/configs/conf-macros 
| rex field=definition max_match=0 "\`(?&amp;lt;themacros&amp;gt;[^\`\(]*)[\`\(]" 
| rex field=id "(?&amp;lt;title&amp;gt;[^\/]*)$"
| table args title them* author definition
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then, depending on what you want to do next, you could put commas between the multiple values...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval themacros=mvjoin(themacros,", ")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 22:22:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289823#M55303</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-01-05T22:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an SPL command using REST to list the macros contained within a macro?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289824#M55304</link>
      <description>&lt;P&gt;AFAIK, there are no such rest end point, not event for other knowledge objects (e.g. saved searches, dashboards etc) which will list dependencies. The rest queries just give details about current object. You probably have to parse it's definition to find any other macro invocation and then run some stats to get the table you expect.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 22:39:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289824#M55304</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-01-05T22:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an SPL command using REST to list the macros contained within a macro?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289825#M55305</link>
      <description>&lt;P&gt;Thank you for your suggestion. ...Great approach! &lt;/P&gt;

&lt;P&gt;I tried it and found that the REGEX on line #2 above just needs an adjustment because sometimes it grabs more than just the macro name. I'm currently getting up-to-speed on REGEX so that I can post an adjustment. I only have a partial suggestion at the moment. This suggestion grabs the macro name as well as the macro argument:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2. | rex field=definition max_match=0 "\`(?&amp;lt;themacros&amp;gt;[^`]*)\`"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to figure out how to get rid of the argument (that is, the parentheses that follow the macro name, as well as the contents of the parentheses.&lt;/P&gt;

&lt;P&gt;For example, the current result is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;macro_name(macro_argument)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I would like to get the following result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;macro_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you again for your approach! Very nice!!!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2018 18:09:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289825#M55305</guid>
      <dc:creator>kdwsplunk</dc:creator>
      <dc:date>2018-01-18T18:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Is there an SPL command using REST to list the macros contained within a macro?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289826#M55306</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;`(?&amp;lt;!\)`)(?&amp;lt;macros&amp;gt;[a-zA-Z][^`\(]*)[\(`]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Apr 2019 15:22:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-an-SPL-command-using-REST-to-list-the-macros-contained/m-p/289826#M55306</guid>
      <dc:creator>landen99</dc:creator>
      <dc:date>2019-04-02T15:22:35Z</dc:date>
    </item>
  </channel>
</rss>

