<?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 JSON-data in Splunk (preferably with Streamsets) in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230034#M44784</link>
    <description>&lt;P&gt;Hi @metadaddy &lt;/P&gt;

&lt;P&gt;I have a similar requirement. I dont have any knowledge on json / java. &lt;/P&gt;

&lt;P&gt;Requirement is to pass everything from a JSON stream (eg: everything from &lt;A href="https://10.24.113.206/container-ws/hystrix.stream"&gt;https://10.24.113.206/container-ws/hystrix.stream&lt;/A&gt;) to Splunk. I have created token for HEC in splunk and googling all blogs to get me work done.&lt;/P&gt;

&lt;P&gt;What should my syntax be if I follow your below example to send everything to Splunk&lt;/P&gt;

&lt;P&gt;Request Data: ${record:value('/timestamp')} User ${record:value('/username')} logged in successfully. (Change this to whatever you want to send to Splunk)&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2019 02:48:37 GMT</pubDate>
    <dc:creator>nareshinsvu</dc:creator>
    <dc:date>2019-04-17T02:48:37Z</dc:date>
    <item>
      <title>Getting JSON-data in Splunk (preferably with Streamsets)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230030#M44780</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;I am new to Splunk and am struggling to get this to work.&lt;/P&gt;

&lt;P&gt;I use Streamsets to add data to my streams. For now I save it in a dummy MongoDB, but I would like to save it directly into Splunk.&lt;/P&gt;

&lt;P&gt;I know about the HTTP Event Collector, but how should I make this connections? What headers and URL should I use?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jan 2017 10:15:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230030#M44780</guid>
      <dc:creator>JosIJntema</dc:creator>
      <dc:date>2017-01-16T10:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Getting JSON-data in Splunk (preferably with Streamsets)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230031#M44781</link>
      <description>&lt;P&gt;I was able to make this work using the StreamSets &lt;A href="https://streamsets.com/documentation/datacollector/latest/help/#Processors/HTTPClient.html#concept_ghx_ypr_fw"&gt;HTTP Client processor&lt;/A&gt;, and the Splunk &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.2/RESTAPI/RESTinput#receivers.2Fsimple"&gt;receivers/simple REST API&lt;/A&gt;. Modeling my HTTP client after the Splunk example, I used the following settings:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Resource URL:&lt;/STRONG&gt; &lt;CODE&gt;&lt;A href="http://localhost:8089/services/receivers/simple?source=${record:value('/source')}&amp;amp;sourcetype=${record:value('/sourcetype')}" target="test_blank"&gt;http://localhost:8089/services/receivers/simple?source=${record:value('/source')}&amp;amp;sourcetype=${record:value('/sourcetype')}&lt;/A&gt;&lt;/CODE&gt; (You can hardcode source, sourcetype if you like)&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;HTTP Method:&lt;/STRONG&gt; POST&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Request Data:&lt;/STRONG&gt; &lt;CODE&gt;${record:value('/timestamp')}  User ${record:value('/username')} logged in successfully.&lt;/CODE&gt; (Change this to whatever you want to send to Splunk)&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Default Request Content Type:&lt;/STRONG&gt; &lt;CODE&gt;application/x-www-form-urlencoded&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Authentication Type:&lt;/STRONG&gt; Basic&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;You'll need to configure an appropriate username/password in the &lt;STRONG&gt;Credentials&lt;/STRONG&gt; tab. I set the data format to XML and passed the API response to a 'Local FS' destination for debugging.&lt;/P&gt;

&lt;P&gt;Note - for simplicity, I &lt;A href="https://answers.splunk.com/answers/93931/splunk-rest-api-without-ssl-i-e-http-only.html"&gt;turned off SSL on the Splunk REST API&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;EDIT: The above mechanism works record-by-record, so it's not very efficient for large amounts of data. A better approach is to use a script to send a single request per batch to the Splunk HTTP Event Collector:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import sys
# Set to wherever the requests package lives on your machine
sys.path.append('/Library/Python/2.7/site-packages')
import requests
import json

# Endpoint for Splunk HTTP Event Collector
url = 'http://localhost:8088/services/collector'

# Read Splunk token from file and cache in state
if state.get('headers') is None:
  state['headers'] = {'Authorization': 'Splunk ${runtime:loadResource('splunkToken', false)}'}

buffer = ''

# Loop through batch, building request payload
for record in records:
  try:
    # Strip host &amp;amp; time fields from record and pass to Splunk as event attributes
    event = dict((key, record.value[key]) for key in record.value if key not in ['time', 'host'])
    buffer += json.dumps({
      'host': record.value['host'],
      'time': record.value['time'],
      'event': event,
    }) + '\n'

    # Write record to processor output
    output.write(record)

  except Exception as e:
    # Send record to error
    error.write(record, str(e))

# Now submit a single request for the entire batch
r = requests.post(url, 
                  headers=state['headers'],
                  data=buffer).json()

# Check for errors from Splunk
if r['code'] != 0:
  log.error('Splunk error: {}: {}', r['code'], r['text'])
  raise Exception('Splunk API error {0}: {1}'.format(r['code'], r['text']))

# All is good
log.info('Splunk API response: {}', r['text'])
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jan 2017 20:42:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230031#M44781</guid>
      <dc:creator>metadaddy</dc:creator>
      <dc:date>2017-01-17T20:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Getting JSON-data in Splunk (preferably with Streamsets)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230032#M44782</link>
      <description>&lt;P&gt;I wrote this up more fully at &lt;A href="https://streamsets.com/blog/ingest-data-splunk-streamsets-data-collector/"&gt;https://streamsets.com/blog/ingest-data-splunk-streamsets-data-collector/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 20:01:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230032#M44782</guid>
      <dc:creator>metadaddy</dc:creator>
      <dc:date>2017-01-18T20:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Getting JSON-data in Splunk (preferably with Streamsets)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230033#M44783</link>
      <description>&lt;P&gt;@JosIJntema - Were you able to test out metadaddy's solution? Did it work? If yes, please don't forget to resolve this post by clicking on "Accept". If you still need more help, please provide a comment with some feedback. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 02:21:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230033#M44783</guid>
      <dc:creator>aaraneta_splunk</dc:creator>
      <dc:date>2017-01-23T02:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting JSON-data in Splunk (preferably with Streamsets)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230034#M44784</link>
      <description>&lt;P&gt;Hi @metadaddy &lt;/P&gt;

&lt;P&gt;I have a similar requirement. I dont have any knowledge on json / java. &lt;/P&gt;

&lt;P&gt;Requirement is to pass everything from a JSON stream (eg: everything from &lt;A href="https://10.24.113.206/container-ws/hystrix.stream"&gt;https://10.24.113.206/container-ws/hystrix.stream&lt;/A&gt;) to Splunk. I have created token for HEC in splunk and googling all blogs to get me work done.&lt;/P&gt;

&lt;P&gt;What should my syntax be if I follow your below example to send everything to Splunk&lt;/P&gt;

&lt;P&gt;Request Data: ${record:value('/timestamp')} User ${record:value('/username')} logged in successfully. (Change this to whatever you want to send to Splunk)&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 02:48:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230034#M44784</guid>
      <dc:creator>nareshinsvu</dc:creator>
      <dc:date>2019-04-17T02:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Getting JSON-data in Splunk (preferably with Streamsets)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230035#M44785</link>
      <description>&lt;P&gt;Hi @nareshinsvu - you could try the &lt;A href="https://streamsets.com/documentation/datacollector/latest/help/datacollector/UserGuide/Destinations/Splunk.html#concept_zzr_pqn_xdb"&gt;Splunk destination&lt;/A&gt; - that was created since I answered this question. Also, we have a few options for our community to interact with the StreamSets team directly - see &lt;A href="https://streamsets.com/community/"&gt;https://streamsets.com/community/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 21:16:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Getting-JSON-data-in-Splunk-preferably-with-Streamsets/m-p/230035#M44785</guid>
      <dc:creator>metadaddy</dc:creator>
      <dc:date>2019-04-17T21:16:56Z</dc:date>
    </item>
  </channel>
</rss>

