<?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: Getting data in via python script or read file? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621933#M216185</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;Thanks for the tips. I managed to get an HEC set up on the Splunk indexer.&lt;/P&gt;&lt;P&gt;I can go to a remote computer and do a curl command like this, which does send data to the indexer:&lt;/P&gt;&lt;P&gt;curl -k &lt;A href="https://Indexer:8088/services/collector/event" target="_blank"&gt;https://Indexer:8088/services/collector/event&lt;/A&gt; -H "Authorization: Splunk 6959a730-556f-4d91-6d94-a6f63fdfb72e" -d '{"event": "amazing transfer of hello world"}'&lt;/P&gt;&lt;P&gt;I am attempting to use a python program with the "requests" module imported, and it seem I need the urllib3 module as well.&lt;/P&gt;&lt;P&gt;I am using json for my header, and json for my data&lt;/P&gt;&lt;P&gt;header { "Authorization": "Splunk &amp;lt;token code from the HEC&amp;gt;" }&lt;/P&gt;&lt;P&gt;et = {"event": "UP hello world, etc" }&lt;/P&gt;&lt;P&gt;my request is this:&lt;/P&gt;&lt;P&gt;req = requests.post(url,headers=header,data=et,verify=False)&lt;/P&gt;&lt;P&gt;This fails with 400, Bad Request.&lt;/P&gt;&lt;P&gt;What am I missing here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;eholz1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Nov 2022 03:01:31 GMT</pubDate>
    <dc:creator>eholz1</dc:creator>
    <dc:date>2022-11-24T03:01:31Z</dc:date>
    <item>
      <title>Is it possible to get data in via python script or read file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621393#M215981</link>
      <description>&lt;P&gt;Hello Splunk Community&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;I have a python script that checks a certain family of cisco devices that tells me if the Device is UP or DOWN. The script is based on a csv file that has hostname and IP.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class=""&gt;
&lt;DIV&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;
&lt;P&gt;The file is not really subject to change, but can be changed easily if required. I wish I could use the Splunk SNMP module, but I need some sort of API key (BaboonBones!??!)&lt;/P&gt;
&lt;P&gt;I can use the script outside of splunk to create a “log” file then have splunk read the file. Maybe that is the best way, I am wondering if it is worthwhile to try to find the splunk python splunklib.client module and use it to send data, etc.&lt;/P&gt;
&lt;P&gt;I am open to suggestions.&lt;/P&gt;
&lt;P&gt;Thanksl,&lt;/P&gt;
&lt;P&gt;eholz1&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sun, 27 Nov 2022 15:48:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621393#M215981</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2022-11-27T15:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data In - via python script or read file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621394#M215982</link>
      <description>&lt;P&gt;Getting data into Splunk from a Python script is easy.&amp;nbsp; Run the script as a Splunk scripted input (Settings-&amp;gt;Data inputs-&amp;gt;scripts).&amp;nbsp; Anything the script writes to stdout will be indexed automatically - no client module needed.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 15:42:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621394#M215982</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-18T15:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data In - via python script or read file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621395#M215983</link>
      <description>&lt;P&gt;Another option is if you want to run the python outside of Splunk for some reason. Send your data in via HTTP event collector.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/georgestarcher/Splunk-Class-httpevent" target="_blank"&gt;https://github.com/georgestarcher/Splunk-Class-httpevent&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 16:07:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621395#M215983</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2022-11-18T16:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data In - via python script or read file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621613#M216072</link>
      <description>&lt;P&gt;Wow two good ideas. I will try it&amp;nbsp; out. One of my main questions would be monitoring a flle or using a&lt;/P&gt;&lt;P&gt;script - is one method better that the othe?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my case, I might have to try the http event collector.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;eholz&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 17:55:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621613#M216072</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2022-11-21T17:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data In - via python script or read file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621615#M216073</link>
      <description>&lt;P&gt;Hello richgalloway,&lt;/P&gt;&lt;P&gt;Again thanks for the tip here, both replies are VERY helpful, If there is a way to give you each 20 karmas&lt;/P&gt;&lt;P&gt;I would.&lt;/P&gt;&lt;P&gt;I will try the script method as well,&lt;/P&gt;&lt;P&gt;eholz1&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 17:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621615#M216073</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2022-11-21T17:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data in via python script or read file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621636#M216080</link>
      <description>&lt;P&gt;Another alternative is REST API (&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTlist" target="_blank" rel="noopener"&gt;Endpoints reference list&lt;/A&gt;, see under receiv ers/). &amp;nbsp;Some pros and cons for your consideration.&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Pro&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Con&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;Scripted input&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Simple, arguably the lowest cost&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Every event carries the name of Spunk server/forwarder as host value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;HEC&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Allows setting of various meta data for each event, such as host&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Specialized interface, some setup&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%"&gt;REST API, e.g.,&amp;nbsp;&lt;DIV&gt;&lt;DIV&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTinput#receivers.2Fsimple" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;/receivers/simple&lt;/SPAN&gt;&lt;/A&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Allows setting of various meta data for each event, such as host&lt;/TD&gt;&lt;TD width="33.333333333333336%"&gt;Requires authentication&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;File dump-ingestion&lt;/TD&gt;&lt;TD&gt;Simple to implement, can set host field per event via path/file name&lt;/TD&gt;&lt;TD&gt;If use path/file name for event, make sure each batch does not contain duplicate path/file name.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 22 Nov 2022 01:06:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621636#M216080</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-11-22T01:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data in via python script or read file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621933#M216185</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;Thanks for the tips. I managed to get an HEC set up on the Splunk indexer.&lt;/P&gt;&lt;P&gt;I can go to a remote computer and do a curl command like this, which does send data to the indexer:&lt;/P&gt;&lt;P&gt;curl -k &lt;A href="https://Indexer:8088/services/collector/event" target="_blank"&gt;https://Indexer:8088/services/collector/event&lt;/A&gt; -H "Authorization: Splunk 6959a730-556f-4d91-6d94-a6f63fdfb72e" -d '{"event": "amazing transfer of hello world"}'&lt;/P&gt;&lt;P&gt;I am attempting to use a python program with the "requests" module imported, and it seem I need the urllib3 module as well.&lt;/P&gt;&lt;P&gt;I am using json for my header, and json for my data&lt;/P&gt;&lt;P&gt;header { "Authorization": "Splunk &amp;lt;token code from the HEC&amp;gt;" }&lt;/P&gt;&lt;P&gt;et = {"event": "UP hello world, etc" }&lt;/P&gt;&lt;P&gt;my request is this:&lt;/P&gt;&lt;P&gt;req = requests.post(url,headers=header,data=et,verify=False)&lt;/P&gt;&lt;P&gt;This fails with 400, Bad Request.&lt;/P&gt;&lt;P&gt;What am I missing here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;eholz1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 03:01:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/621933#M216185</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2022-11-24T03:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data in via python script or read file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/622027#M216204</link>
      <description>&lt;P&gt;Why do you need JSON for auth header? &amp;nbsp;As your cURL command demonstrated, it should be a colon-separated key-value pair.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 22:07:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/622027#M216204</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-11-24T22:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Getting Data In - via python script or read file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/622278#M216310</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;Thanks for all the replies Yes, I used the HEC, and finally got everyting working.&lt;/P&gt;&lt;P&gt;I am using&amp;nbsp; the request module to send the data to splunk. The tricking part was&amp;nbsp; making the data value a STRING. The authorization goes through fine in the "json" format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the support&lt;/P&gt;&lt;P&gt;eholz1&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 15:32:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-get-data-in-via-python-script-or-read-file/m-p/622278#M216310</guid>
      <dc:creator>eholz1</dc:creator>
      <dc:date>2022-11-28T15:32:07Z</dc:date>
    </item>
  </channel>
</rss>

