<?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: REST API Modular Input in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142227#M12352</link>
    <description>&lt;P&gt;whoa - works like a charm &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2013 11:58:37 GMT</pubDate>
    <dc:creator>preben12</dc:creator>
    <dc:date>2013-11-15T11:58:37Z</dc:date>
    <item>
      <title>REST API Modular Input</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142224#M12349</link>
      <description>&lt;P&gt;I calling a remote http endpoint that returns xml in the form of&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;AdaptersStatus xmlns="http://xx.xx/xxxx/services/monitoring"&amp;gt;
   &amp;lt;Status&amp;gt;ERROR&amp;lt;/Status&amp;gt;
   &amp;lt;Timestamp&amp;gt;2013-11-14T13:33:48&amp;lt;/Timestamp&amp;gt;
   &amp;lt;MonitoredAdapterStatus&amp;gt;
      &amp;lt;Status&amp;gt;
         &amp;lt;Timestamp&amp;gt;2013-11-14T13:33:47&amp;lt;/Timestamp&amp;gt;
         &amp;lt;ApplicationStatus&amp;gt;OK&amp;lt;/ApplicationStatus&amp;gt;
         &amp;lt;ApplicationVersion&amp;gt;1.0.19&amp;lt;/ApplicationVersion&amp;gt;
         &amp;lt;MonitoredRessources&amp;gt;
            &amp;lt;DisplayName&amp;gt;Route monitor :: audit-trail-Route&amp;lt;/DisplayName&amp;gt;
            &amp;lt;Status&amp;gt;OK&amp;lt;/Status&amp;gt;
         &amp;lt;/MonitoredRessources&amp;gt;
         &amp;lt;MonitoredRessources&amp;gt;
             &amp;lt;DisplayName&amp;gt;Route monitor :: bam-route&amp;lt;/DisplayName&amp;gt;
             &amp;lt;Status&amp;gt;OK&amp;lt;/Status&amp;gt;
         &amp;lt;/MonitoredRessources&amp;gt;
     &amp;lt;/Status&amp;gt;
     &amp;lt;Configuration&amp;gt;
        &amp;lt;URL&amp;gt;http://xxxxxx:7003/audit-trail/status&amp;lt;/URL&amp;gt;
        &amp;lt;AdapterName&amp;gt;audit-trail&amp;lt;/AdapterName&amp;gt;
     &amp;lt;/Configuration&amp;gt;
  &amp;lt;/MonitoredAdapterStatus&amp;gt; 
&amp;lt;/AdaptersStatus&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm actually only interested in indexing the first &lt;STATUS&gt; field and the &lt;TIMESTAMP&gt; field, in this case &lt;STATUS&gt;ERROR&lt;/STATUS&gt;, &lt;TIMESTAMP&gt;2013-11-14Tx&lt;/TIMESTAMP&gt;, and a sourcetype that indicates what rest service has been called.&lt;/TIMESTAMP&gt;&lt;/STATUS&gt;&lt;/P&gt;

&lt;P&gt;I figured out that if I do = | rex "(?i)&amp;lt;.*?&amp;gt;(?P&lt;STATUS&gt;\w+)(?=&amp;lt;)" I will get a Key value of the Status field, but how can i make rest_ta index that, and discard the rest of the xml response ?&lt;/STATUS&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2013 12:50:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142224#M12349</guid>
      <dc:creator>preben12</dc:creator>
      <dc:date>2013-11-14T12:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142225#M12350</link>
      <description>&lt;P&gt;The REST API Modular Input is generic ie: it can be used against any HTTP REST endpoint. So it has the ability to plugin custom response handlers for any custom pre-processing or formatting of your response data.&lt;/P&gt;

&lt;P&gt;To do this you add a custom response handler class to &lt;STRONG&gt;etc/apps/rest_ta/bin/responsehandlers.py&lt;/STRONG&gt;  and in the stanza setup declare that this handler should be applied.&lt;/P&gt;

&lt;P&gt;So you could write  a handler to just strip out and index the elements you are interested in.&lt;/P&gt;

&lt;P&gt;Very quick rough code : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;class MyCustomResponseHandler:

    def __init__(self,**args):
        pass

    def __call__(self, response_object,raw_response_output,response_type,req_args,endpoint):

        from xml.dom import minidom
        dom = minidom.parseString(raw_response_output)
        status = dom.getElementsByTagName('Status')
        timestamp = dom.getElementsByTagName('Timestamp')
        status[0].firstChild.nodeValue
        timestamp[0].firstChild.nodeValue

        processed_response_output = 'status='+status[0].firstChild.nodeValue+' timestamp='+timestamp[0].firstChild.nodeValue

        print_xml_stream(processed_response_output)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;IMG src="http://answers.splunk.com//storage/Screen_Shot_2013-11-14_at_9.30.31_PM.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2013 14:32:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142225#M12350</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2013-11-14T14:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142226#M12351</link>
      <description>&lt;P&gt;Thanks Damien&lt;BR /&gt;
I'll give your suggestions a try.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 10:59:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142226#M12351</guid>
      <dc:creator>preben12</dc:creator>
      <dc:date>2013-11-15T10:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142227#M12352</link>
      <description>&lt;P&gt;whoa - works like a charm &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 11:58:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142227#M12352</guid>
      <dc:creator>preben12</dc:creator>
      <dc:date>2013-11-15T11:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142228#M12353</link>
      <description>&lt;P&gt;Cool, not bad for untested code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 12:26:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/REST-API-Modular-Input/m-p/142228#M12353</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2013-11-15T12:26:00Z</dc:date>
    </item>
  </channel>
</rss>

