<?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 Extracting values from a json log file in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-values-from-a-json-log-file/m-p/389430#M69694</link>
    <description>&lt;P&gt;I have log file that looks like the following:&lt;/P&gt;

&lt;P&gt;what's the best way to extract each value here. I want to evetually download this as a csv file. I'm okay with the dictionary/json for message still being a dictionary/json.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"source_host":"a.com","method":"new","level":"INFO","message":"value = {\"sessionId\" :\"1\",\"number\":\"2\"}"}     
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried using &lt;CODE&gt;| spath output=_raw path=source_host&lt;/CODE&gt;, but and that worked, but I can't get multiple fields e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath output=_raw path=source_host|method 
| spath output=_raw path=source_host,method
| spath output=_raw path=*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jul 2018 15:40:41 GMT</pubDate>
    <dc:creator>Splunkster45</dc:creator>
    <dc:date>2018-07-31T15:40:41Z</dc:date>
    <item>
      <title>Extracting values from a json log file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-values-from-a-json-log-file/m-p/389430#M69694</link>
      <description>&lt;P&gt;I have log file that looks like the following:&lt;/P&gt;

&lt;P&gt;what's the best way to extract each value here. I want to evetually download this as a csv file. I'm okay with the dictionary/json for message still being a dictionary/json.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"source_host":"a.com","method":"new","level":"INFO","message":"value = {\"sessionId\" :\"1\",\"number\":\"2\"}"}     
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried using &lt;CODE&gt;| spath output=_raw path=source_host&lt;/CODE&gt;, but and that worked, but I can't get multiple fields e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath output=_raw path=source_host|method 
| spath output=_raw path=source_host,method
| spath output=_raw path=*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 15:40:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-values-from-a-json-log-file/m-p/389430#M69694</guid>
      <dc:creator>Splunkster45</dc:creator>
      <dc:date>2018-07-31T15:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from a json log file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-values-from-a-json-log-file/m-p/389431#M69695</link>
      <description>&lt;P&gt;Give this a try &lt;CODE&gt;|spath output=_raw | table *&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If you want to extract multiple values, have a look &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.2/SearchReference/Spath#7:_Extract_and_expand_JSON_events_with_multi-valued_fields"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 16:08:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-values-from-a-json-log-file/m-p/389431#M69695</guid>
      <dc:creator>sudosplunk</dc:creator>
      <dc:date>2018-07-31T16:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting values from a json log file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extracting-values-from-a-json-log-file/m-p/389432#M69696</link>
      <description>&lt;P&gt;Just use the spath command (no other parameter) to extract all fields, as long as your raw data is in pure json format. See this runanywhere sample based off your sample data (additional backslashes are added to inline data generation)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval _raw="{\"source_host\":\"a.com\",\"method\":\"new\",\"level\":\"INFO\",\"message\":\"value = {\\\"sessionId\\\" :\\\"1\\\",\\\"number\\\":\\\"2\\\"}\"}" | table _raw 
| spath
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:45:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extracting-values-from-a-json-log-file/m-p/389432#M69696</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-07-31T17:45:32Z</dc:date>
    </item>
  </channel>
</rss>

