<?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: Split json into multiple events and sourcetype in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Split-json-into-multiple-events-and-sourcetype/m-p/377060#M68236</link>
    <description>&lt;P&gt;i could be wrong, but i don't think this is possible at parse/index time.  One of the first things splunk will do is break the stream of data into events...and it only does that once.  At that point, if you want just one id/host object per event, you've lost the context of masters/slaves and i don't think you can get it back.  The option of large events with multiple objects would allow you to set the sourcetype the way you want i think, but then you have giant events with many id/host objects.&lt;/P&gt;

&lt;P&gt;maybe you could break into large "masters" and "slaves" events and then come back around at search time with the collect command to split it up the way you want.&lt;/P&gt;

&lt;P&gt;Of course if you can change the source and just split it up before you send to splunk, then that's a good option as well.&lt;/P&gt;

&lt;P&gt;Curious too if this sort of problem might be a use case for the Data Stream Processor that's in beta now&lt;BR /&gt;
&lt;A href="https://www.splunk.com/en_us/software/splunk-next.html"&gt;https://www.splunk.com/en_us/software/splunk-next.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 09 Feb 2019 00:48:28 GMT</pubDate>
    <dc:creator>maciep</dc:creator>
    <dc:date>2019-02-09T00:48:28Z</dc:date>
    <item>
      <title>Split json into multiple events and sourcetype</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Split-json-into-multiple-events-and-sourcetype/m-p/377059#M68235</link>
      <description>&lt;P&gt;Lets say I have the following json data onboarded.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  {
       "slaves": [{
              "id": "1234",
              "hostname": "12556"
       },
       {
              "id": "1245",
              "hostname": "1266"
       }]
      "masters": [{
              "id": "2234",
              "hostname": "22556"
       },
       {
              "id": "2245",
              "hostname": "2266"
       }]
  }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The result that I want is that for each slave I get an event with sourcetype indexnamex:slave and for each master I want to put each event in sourcetype indexnamex:master&lt;/P&gt;

&lt;P&gt;So in indexnamex:slave I want 2 events&lt;/P&gt;

&lt;P&gt;indexnamex:slave &lt;STRONG&gt;Event1&lt;/STRONG&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;{"id": "1234","hostname": "12556" }&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;indexnamex:slave &lt;STRONG&gt;Event2&lt;/STRONG&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;{  "id": "1245", "hostname": "1266" }&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;And in  indexnamex:master also two events&lt;/P&gt;

&lt;P&gt;indexnamex:master &lt;STRONG&gt;Event 1&lt;/STRONG&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;{ "id": "2234", "hostname": "22556"  }&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;indexnamex:master &lt;STRONG&gt;Event 2&lt;/STRONG&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;{ "id": "2245", "hostname": "2266" }&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I can not split on e.g. hostname x } as it is the same for slaves and masters.&lt;BR /&gt;
Is it possible to do splitting in multiple steps?&lt;BR /&gt;
e.g. first split on "slaves" : and "masters":&lt;BR /&gt;
and after that split do a split on what is left?&lt;/P&gt;

&lt;P&gt;If not are there any other options?&lt;/P&gt;

&lt;P&gt;note: the example is simpler than my real data as it is 10k lines.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 14:20:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Split-json-into-multiple-events-and-sourcetype/m-p/377059#M68235</guid>
      <dc:creator>sboogaar</dc:creator>
      <dc:date>2019-02-08T14:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Split json into multiple events and sourcetype</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Split-json-into-multiple-events-and-sourcetype/m-p/377060#M68236</link>
      <description>&lt;P&gt;i could be wrong, but i don't think this is possible at parse/index time.  One of the first things splunk will do is break the stream of data into events...and it only does that once.  At that point, if you want just one id/host object per event, you've lost the context of masters/slaves and i don't think you can get it back.  The option of large events with multiple objects would allow you to set the sourcetype the way you want i think, but then you have giant events with many id/host objects.&lt;/P&gt;

&lt;P&gt;maybe you could break into large "masters" and "slaves" events and then come back around at search time with the collect command to split it up the way you want.&lt;/P&gt;

&lt;P&gt;Of course if you can change the source and just split it up before you send to splunk, then that's a good option as well.&lt;/P&gt;

&lt;P&gt;Curious too if this sort of problem might be a use case for the Data Stream Processor that's in beta now&lt;BR /&gt;
&lt;A href="https://www.splunk.com/en_us/software/splunk-next.html"&gt;https://www.splunk.com/en_us/software/splunk-next.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Feb 2019 00:48:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Split-json-into-multiple-events-and-sourcetype/m-p/377060#M68236</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2019-02-09T00:48:28Z</dc:date>
    </item>
  </channel>
</rss>

