<?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: Extract event fields in desired format in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99217#M20763</link>
    <description>&lt;P&gt;How could I achieve that ? I realize that my question may sound ridiculous , but I just recently crushed Pyhton Programming.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Oct 2013 12:07:42 GMT</pubDate>
    <dc:creator>rantravee</dc:creator>
    <dc:date>2013-10-15T12:07:42Z</dc:date>
    <item>
      <title>Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99213#M20759</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;

&lt;P&gt;I'd need some hints regarding the propertiesI should have in in props.conf and transforms.conf so that I have data in the needed format. So I within my scripted input I print to standard output a json object of the following format&lt;/P&gt;

&lt;P&gt;{&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"statistics" :[{stats_resource_json_obj_1},....,{stats_resource_json_obj_n}]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;each &lt;CODE&gt;stats_resource_json_obj_i&lt;/CODE&gt; has the folowing format &lt;BR /&gt;
{&lt;BR /&gt;
  "id":value,&lt;BR /&gt;
  ............&lt;BR /&gt;
  "stat_i":"val_i"&lt;BR /&gt;
}&lt;BR /&gt;
I would like to have an event for each &lt;CODE&gt;stats-resource-json-obj&lt;/CODE&gt;  and to have recognized/extracted as fields (at search time) every pair of key/value within the object .&lt;/P&gt;

&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:58:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99213#M20759</guid>
      <dc:creator>rantravee</dc:creator>
      <dc:date>2020-09-28T14:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99214#M20760</link>
      <description>&lt;P&gt;In your props.conf, make sure that your &lt;CODE&gt;KV_MODE&lt;/CODE&gt; is set to &lt;CODE&gt;JSON&lt;/CODE&gt;. In order to split up the events, since you have control of the script, I'd rework the script to print a new json object on each line, Splunk should handle the rest. &lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2013 11:18:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99214#M20760</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-10-15T11:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99215#M20761</link>
      <description>&lt;P&gt;It seems Splunk is incapable of automatically extracting the fields .Only the default fields are extracted . I see a long string ,containing all the key/pair values . Something like &lt;/P&gt;

&lt;P&gt;{'stat_1': 0, 'stat_2': 0, 'stat_3': 0, 'stat_4': 0, 'stat_4': 0, ....., 'stat_n': 0 }&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:58:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99215#M20761</guid>
      <dc:creator>rantravee</dc:creator>
      <dc:date>2020-09-28T14:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99216#M20762</link>
      <description>&lt;P&gt;remove the single quotes from the field names.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2013 11:45:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99216#M20762</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-10-15T11:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99217#M20763</link>
      <description>&lt;P&gt;How could I achieve that ? I realize that my question may sound ridiculous , but I just recently crushed Pyhton Programming.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2013 12:07:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99217#M20763</guid>
      <dc:creator>rantravee</dc:creator>
      <dc:date>2013-10-15T12:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99218#M20764</link>
      <description>&lt;P&gt;I would need to see a pastebin of you code to see what you are doing to accurately diagnose it.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2013 12:18:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99218#M20764</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-10-15T12:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99219#M20765</link>
      <description>&lt;P&gt;def printResponseToSplunk(self,s):&lt;BR /&gt;
    jdata = json.loads(s)&lt;BR /&gt;&lt;BR /&gt;
  # Augment json  object with additional information&lt;BR /&gt;
  stats = jdata[JSON_STATS_OBJ_NAME]        &lt;/P&gt;

&lt;P&gt;for innerOBj in stats&lt;BR /&gt;
      innerOBj[JSON_CHASSIS_KEY]=self.getHost()&lt;BR /&gt;
      print (json.dumps(innerOBj))&lt;BR /&gt;
      sys.stdout.flush()&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99219#M20765</guid>
      <dc:creator>rantravee</dc:creator>
      <dc:date>2020-09-28T14:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99220#M20766</link>
      <description>&lt;P&gt;Can you paste the entire script to pastebin please? I want to see how you are crafting the string that you then dump with the json object. Don't forget we can help you out in Real Time on the IRC #splunk channel on efnet. &lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2013 12:30:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99220#M20766</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-10-15T12:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99221#M20767</link>
      <description>&lt;P&gt;Thanks for the channel hint. I was unware of that.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2013 12:32:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99221#M20767</guid>
      <dc:creator>rantravee</dc:creator>
      <dc:date>2013-10-15T12:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Extract event fields in desired format</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99222#M20768</link>
      <description>&lt;P&gt;The json obj comes in the format described in the question from a network resource : &lt;/P&gt;

&lt;P&gt;resp, content = http.request(statistics_url,&lt;BR /&gt;
            method='POST',&lt;BR /&gt;
            headers={'Content-Type': 'application/json', 'charset':'UTF-8','Connection':'keep-alive', 'Host':'theHost'}, body=json_body)&lt;/P&gt;

&lt;P&gt;and then I call printResponseToSplunk(), passing the content object to it&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 14:58:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-event-fields-in-desired-format/m-p/99222#M20768</guid>
      <dc:creator>rantravee</dc:creator>
      <dc:date>2020-09-28T14:58:22Z</dc:date>
    </item>
  </channel>
</rss>

