<?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: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!) in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261596#M50232</link>
    <description>&lt;P&gt;Do not use the backslashes (). The command works fine without them.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2018 01:05:31 GMT</pubDate>
    <dc:creator>pinterl</dc:creator>
    <dc:date>2018-01-23T01:05:31Z</dc:date>
    <item>
      <title>HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261586#M50222</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;(Not Splunk questions per say...)&lt;/P&gt;

&lt;P&gt;I'm setting up the HTTP Event Collector, so that our chef recipes can log to Splunk and we can have stats on it's usefulness and such...&lt;/P&gt;

&lt;P&gt;I was able to communicate in the chef recipe to the HEC, using a basic curl command.  Now, I want to pass the hostname of the server where I'm running, but having problems getting that HOSTNAME variable to appear.  Wondering if any Linux guru's out there can help me out... OR.... help me map out how chef does an http_request to the Splunk parameters.&lt;/P&gt;

&lt;P&gt;So, here's the curl command and the results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k &lt;A href="https://myserver.com:8088/services/collector/event" target="test_blank"&gt;https://myserver.com:8088/services/collector/event&lt;/A&gt; -H 'Authorization: Splunk 7E36213E-03E1-4246-93B9-81931D303A58' -d '{"event": "hello from ""'"$HOSTNAME"'""}'
{"text":"Invalid data format","code":6,"invalid-event-number":0}[a212830@vc2crtp1102248n ~]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I just say "hello world" it works.  But passing in the hostname variable throws a wrench into it.  &lt;/P&gt;

&lt;P&gt;That said, chef has an http_request function, but I'm not sure how to map the required Splunk parameters to it. Anyone tried it?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;http_request 'posting data' do
  action :post
  url 'http://example.com/check_in'
  message ({:some =&amp;gt; 'data'}.to_json)
  headers({'AUTHORIZATION' =&amp;gt; "Basic #{
    Base64.encode64('username:password')}",
    'Content-Type' =&amp;gt; 'application/data'
  })
end
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 15:12:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261586#M50222</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-08-30T15:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261587#M50223</link>
      <description>&lt;P&gt;Definitely more of a curl issue than a HEC issue, but I was able to get it to work right with the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k &lt;A href="https://&amp;lt;splunk-server&amp;gt;:8088/services/collector/event" target="test_blank"&gt;https://&amp;lt;splunk-server&amp;gt;:8088/services/collector/event&lt;/A&gt; -H 'Authorization: Splunk &amp;lt;HEC Token&amp;gt;' -d"{\"event\": \"hello $HOSTNAME\", \"index\":\"&amp;lt;Index Name&amp;gt;\", \"host\":\"$HOSTNAME\"}"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 17:26:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261587#M50223</guid>
      <dc:creator>scottjpack</dc:creator>
      <dc:date>2016-08-30T17:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261588#M50224</link>
      <description>&lt;P&gt;Agreed.  Not a HEC issue.  &lt;/P&gt;

&lt;P&gt;Same error though:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[a212830@vc2crtp1102248n ~]$ echo $HOSTNAME
vc2crtp1102248n.fmr.com
[a212830@vc2crtp1102248n ~]$ curl -k &lt;A href="https://myserver.com:8088/services/collector/event" target="test_blank"&gt;https://myserver.com:8088/services/collector/event&lt;/A&gt; -H 'Authorization: Splunk 7E36213E-03E1-4246-93B9-81931D303A58' -d"{\"event\": \"hello $HOSTNAME\", \"index\":\"&amp;lt;Index Name&amp;gt;\", \"host\":\"$HOSTNAME\"}"
{"text":"Incorrect index","code":7,"invalid-event-number":1}[a212830@vc2crtp1102248n ~]$
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 17:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261588#M50224</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-08-30T17:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261589#M50225</link>
      <description>&lt;P&gt;Try specifying an index that the HEC has access to write to, I get weird stuff if no index is specified.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 17:58:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261589#M50225</guid>
      <dc:creator>scottjpack</dc:creator>
      <dc:date>2016-08-30T17:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261590#M50226</link>
      <description>&lt;P&gt;Bingo!  I accepted the answer.  Do you automatically get the points? &lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:33:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261590#M50226</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-08-30T18:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261591#M50227</link>
      <description>&lt;P&gt;One way is to send "host" in the request as you are doing here. Alternatively you can configure Splunk per token, so it will resolve the host based on the client that is sending. You do this in inputs.conf under the token stanza by setting the connection_host to "ip" or "dns". You can see the setting &lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.2/Admin/Inputsconf#http:"&gt;here&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;connection_host = [ip|dns|none]
* Specify the host if an event doesn't have host set.
* "ip" sets the host to the IP address of the system sending the data. 
* "dns" sets the host to the reverse DNS entry for IP address of the system sending the data.
* "none" leaves the host as specified in the HTTP header.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:56:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261591#M50227</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-08-30T18:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261592#M50228</link>
      <description>&lt;P&gt;Looks like they were awarded.  Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 19:07:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261592#M50228</guid>
      <dc:creator>scottjpack</dc:creator>
      <dc:date>2016-08-30T19:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261593#M50229</link>
      <description>&lt;P&gt;fyi for those who have chef and want to do the same thing via http_request:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  http_request 'posting data' do
  action :post
  url "https://myserver.com:8088/services/collector/event"
  message ({:event =&amp;gt; "splunk installer complete.  type=#{type}", :host =&amp;gt; "#{HOSTNAME} ", :index =&amp;gt; "main"}.to_json)
  headers({
    'Authorization' =&amp;gt; 'Splunk 7E36213E-03E1-4246-93B9-81931D303A58'
  })
end
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2016 01:14:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261593#M50229</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-08-31T01:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261594#M50230</link>
      <description>&lt;P&gt;Just to clarify, the config setting above will allow you to configure this on the Splunk side so the client doesn't have to send it.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 01:20:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261594#M50230</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2016-08-31T01:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261595#M50231</link>
      <description>&lt;P&gt;Can I use splunk light cloud  for this ? I am trying and it does not work. What URL should I use?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;1st attempt&lt;/STRONG&gt;&lt;BR /&gt;
&lt;A href="https://prd-p-xxxxxxx.cloud.splunk.com:8088/services/collector/event"&gt;https://prd-p-xxxxxxx.cloud.splunk.com:8088/services/collector/event&lt;/A&gt;&lt;BR /&gt;
result: time out&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;2nd attempt&lt;/STRONG&gt;&lt;BR /&gt;
&lt;A href="https://input-prd-p-XXXXXXX.cloud.splunk.com:8088/services/collector/event"&gt;https://input-prd-p-XXXXXXX.cloud.splunk.com:8088/services/collector/event&lt;/A&gt;&lt;BR /&gt;
result: time out&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;3rd attempt&lt;/STRONG&gt;&lt;BR /&gt;
result: time out&lt;BR /&gt;
&lt;A href="https://http-inputs-XXXXXXXX.splunkcloud.com/services/collector/event"&gt;https://http-inputs-XXXXXXXX.splunkcloud.com/services/collector/event&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 22:14:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261595#M50231</guid>
      <dc:creator>sogema</dc:creator>
      <dc:date>2017-09-13T22:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261596#M50232</link>
      <description>&lt;P&gt;Do not use the backslashes (). The command works fine without them.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 01:05:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261596#M50232</guid>
      <dc:creator>pinterl</dc:creator>
      <dc:date>2018-01-23T01:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Event Collector and curl: How to pass the hostname variable in Chef? (BOUNTY!)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261597#M50233</link>
      <description>&lt;P&gt;it worked very fine for me, tnx!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 11:19:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/HTTP-Event-Collector-and-curl-How-to-pass-the-hostname-variable/m-p/261597#M50233</guid>
      <dc:creator>marco_gomiero</dc:creator>
      <dc:date>2020-02-13T11:19:15Z</dc:date>
    </item>
  </channel>
</rss>

