<?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: Modular input script execution in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-script-execution/m-p/357496#M5771</link>
    <description>&lt;P&gt;Is there any way to do that??&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 16:15:00 GMT</pubDate>
    <dc:creator>manudbc</dc:creator>
    <dc:date>2018-03-19T16:15:00Z</dc:date>
    <item>
      <title>Modular input script execution</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-script-execution/m-p/357495#M5770</link>
      <description>&lt;P&gt;hello I have a modular input script which estract data from a external source with a interval ejecution this script has an Schema, I wont to use the schema data for a script ejecution in search&lt;BR /&gt;
Modular input scheme script:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import json
import time
import urllib2

from splunklib.modularinput import *


class MyScript(Script):

    def get_scheme(self):

        scheme = Scheme("x")
        scheme.description = ("x")
        scheme.use_external_validation = True
        scheme.use_single_instance = False

        api_arg = Argument(
            name="api",
            title="API Code",
            data_type=Argument.data_type_string,
            required_on_create=True,
            required_on_edit=True
        )
        scheme.add_argument(api_arg)


        return scheme

    def validate_input(self, definition):
        api = definition.parameters["api"]

    def stream_events(self, inputs, ew):
            api = input_item["api"]
            list=[]
            count=0
            try:
                r = urllib2.Request("URLLLLLLL".format(api))
                t = json.loads(urllib2.urlopen(r).read())

                    logevent = Event()
                    logevent.stanza = input_name
                    logevent.data = json.dumps(t, sort_keys=True, separators=(',',':'))
                    ew.write_event(logevent)

if __name__ == "__main__":
    exitcode = MyScript().run(sys.argv)
    sys.exit(exitcode)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;using following search&lt;/P&gt;

&lt;P&gt;| script commandname arg1 arg2&lt;/P&gt;

&lt;P&gt;my script use api schema  data and update or add events to my index&lt;BR /&gt;
¿any example of my script?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 21:52:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Modular-input-script-execution/m-p/357495#M5770</guid>
      <dc:creator>manudbc</dc:creator>
      <dc:date>2018-03-16T21:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Modular input script execution</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-script-execution/m-p/357496#M5771</link>
      <description>&lt;P&gt;Is there any way to do that??&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 16:15:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Modular-input-script-execution/m-p/357496#M5771</guid>
      <dc:creator>manudbc</dc:creator>
      <dc:date>2018-03-19T16:15:00Z</dc:date>
    </item>
  </channel>
</rss>

