<?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: Curl Command: Why is getting data into Splunk with Python https request so slow? in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380584#M46331</link>
    <description>&lt;P&gt;Thanks, didn't find that on my own... &lt;BR /&gt;
Oh and I see your the author, nice work! &lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2019 19:18:15 GMT</pubDate>
    <dc:creator>henne959</dc:creator>
    <dc:date>2019-05-22T19:18:15Z</dc:date>
    <item>
      <title>Curl Command: Why is getting data into Splunk with Python https request so slow?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380580#M46327</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I am testing a simple Python script to load data into Splunk using the HTTP-Event-Collector.&lt;BR /&gt;
The data comes in so this is not the problem but the time the script takes to send each datapoint.&lt;/P&gt;

&lt;P&gt;My script:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import datetime
import random
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)



import requests

headers = {
    'Authorization': 'Splunk 7da83bdd-7d7c-4603-b814-fc505fec312a', 'Connection': 'close'
}

for i in range(1,20):
    t = datetime.datetime.now()
    timestamp = str(t.timestamp())
    data = '{"sourcetype":"_json_adv","time":"'+timestamp+'", "event":{"name":"uwu","value":"'+str(random.uniform(0,100))+'"}}'


    response = requests.post('https://localhost:8088/services/collector', headers=headers, data=data, verify=False)


    print(response.elapsed)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The statement &lt;CODE&gt;print(response.elapsed)&lt;/CODE&gt; prints this out:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;0:00:01.005077
0:00:01.004486
0:00:01.004662
0:00:01.004560
0:00:01.006372
0:00:01.008843
0:00:01.005079
0:00:01.015055
0:00:01.006656
0:00:01.004583
0:00:01.003251
0:00:01.003271
0:00:01.004073
0:00:01.007512
0:00:01.005102
0:00:01.006401
0:00:01.006413
0:00:01.005493
0:00:01.005120
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The statement &lt;CODE&gt;print(response.headers)&lt;/CODE&gt; prints this out:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{'Date': 'Tue, 21 May 2019 18:00:03 GMT', 
'Content-Type': 'application/json; 
charset=UTF-8', 
'X-Content-Type-Options': 'nosniff', 
'Content-Length': '27', 
'Vary': 'Authorization',
'Connection': 'Close', 
'X-Frame-Options': 'SAMEORIGIN', 
'Server': 'Splunkd'}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In another thread on Github (&lt;A href="https://github.com/kennethreitz/requests/issues/4023"&gt;https://github.com/kennethreitz/requests/issues/4023&lt;/A&gt;) I stumbled upon the statement &lt;CODE&gt;'Connection': 'Close'&lt;/CODE&gt; in the request header to speed it up but that didn't shortened the time for each request.&lt;BR /&gt;
I tried another request at some test website with response times &amp;lt;200ms. &lt;BR /&gt;
For me it seems to be a problem with the splunk server.&lt;/P&gt;

&lt;P&gt;Anybody know a solution to speed this up? &lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 18:12:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380580#M46327</guid>
      <dc:creator>henne959</dc:creator>
      <dc:date>2019-05-21T18:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Curl Command: Why is getting data into Splunk with Python https request so slow?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380581#M46328</link>
      <description>&lt;P&gt;In the end I want to read the data with the script from a PLC and forward it Splunk this way. Therefore multiple datapoints have to be sent in &amp;lt;1s.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 18:16:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380581#M46328</guid>
      <dc:creator>henne959</dc:creator>
      <dc:date>2019-05-21T18:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Curl Command: Why is getting data into Splunk with Python https request so slow?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380582#M46329</link>
      <description>&lt;P&gt;The header I send is &lt;BR /&gt;
    {'User-Agent': 'python-requests/2.18.4', &lt;BR /&gt;
    'Accept-Encoding': 'gzip, deflate', &lt;BR /&gt;
    'Accept': '&lt;EM&gt;/&lt;/EM&gt;',&lt;BR /&gt;
    'Connection': 'close',&lt;BR /&gt;
     'Authorization': 'Splunk 7da83bdd-7d7c-4603-b814-fc505fec312a',&lt;BR /&gt;
     'Content-Length': '105'}&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 18:19:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380582#M46329</guid>
      <dc:creator>henne959</dc:creator>
      <dc:date>2019-05-21T18:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Curl Command: Why is getting data into Splunk with Python https request so slow?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380583#M46330</link>
      <description>&lt;P&gt;&lt;A href="https://github.com/georgestarcher/Splunk-Class-httpevent"&gt;https://github.com/georgestarcher/Splunk-Class-httpevent&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 18:30:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380583#M46330</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2019-05-22T18:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Curl Command: Why is getting data into Splunk with Python https request so slow?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380584#M46331</link>
      <description>&lt;P&gt;Thanks, didn't find that on my own... &lt;BR /&gt;
Oh and I see your the author, nice work! &lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 19:18:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Curl-Command-Why-is-getting-data-into-Splunk-with-Python-https/m-p/380584#M46331</guid>
      <dc:creator>henne959</dc:creator>
      <dc:date>2019-05-22T19:18:15Z</dc:date>
    </item>
  </channel>
</rss>

