<?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 How to parse the payload inside a csv log to run a stats count search on the extracted fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152007#M42601</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;What would be the simplest way of parsing the following logs so I can search what is inside the {} field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Feb 25, 2015 11:59 PM",20,PreviewScreen_Next,,201502051926,iPhone,Apple iPhone 6,51FC9233-F23B-44FA-B3CC-E91F56F26C30,{ field1 : Original;  media : MediaType;  post : mu},
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The name of the field in the csv is "Params". All the other fields are fine as I can search them, but I need to be able to do a stats count by media for example.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 26 Feb 2015 12:18:54 GMT</pubDate>
    <dc:creator>anthonycopus</dc:creator>
    <dc:date>2015-02-26T12:18:54Z</dc:date>
    <item>
      <title>How to parse the payload inside a csv log to run a stats count search on the extracted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152007#M42601</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;What would be the simplest way of parsing the following logs so I can search what is inside the {} field:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Feb 25, 2015 11:59 PM",20,PreviewScreen_Next,,201502051926,iPhone,Apple iPhone 6,51FC9233-F23B-44FA-B3CC-E91F56F26C30,{ field1 : Original;  media : MediaType;  post : mu},
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The name of the field in the csv is "Params". All the other fields are fine as I can search them, but I need to be able to do a stats count by media for example.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 12:18:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152007#M42601</guid>
      <dc:creator>anthonycopus</dc:creator>
      <dc:date>2015-02-26T12:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse the payload inside a csv log to run a stats count search on the extracted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152008#M42602</link>
      <description>&lt;P&gt;Hi anthonycopus,&lt;/P&gt;

&lt;P&gt;try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search here | rex "field1\s:\s(?&amp;lt;field1&amp;gt;.+?);\s+media\s:\s(?&amp;lt;media&amp;gt;.+?);\s+post\s:\s(?&amp;lt;post&amp;gt;.+?)}" | stats count by media
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope that helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 12:34:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152008#M42602</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-02-26T12:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse the payload inside a csv log to run a stats count search on the extracted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152009#M42603</link>
      <description>&lt;P&gt;Thanks, this works. Is there a combination which would work if the logs follow this trend, but some may have more fields than others? E.g. one log has field1 and media in the payload, but the other has only field1&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 14:25:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152009#M42603</guid>
      <dc:creator>anthonycopus</dc:creator>
      <dc:date>2015-02-26T14:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse the payload inside a csv log to run a stats count search on the extracted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152010#M42604</link>
      <description>&lt;P&gt;You could setup field extraction for each field separately, take a look at the docs here &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/Knowledge/ExtractfieldsinteractivelywithIFX"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.2/Knowledge/ExtractfieldsinteractivelywithIFX&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 16:13:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152010#M42604</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-02-26T16:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse the payload inside a csv log to run a stats count search on the extracted fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152011#M42605</link>
      <description>&lt;P&gt;The content of that field is ALMOST json, which would make it super easy to parse.  If it were:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"field1": "Original", "media": "MediaType", "post": "mu"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could use the &lt;CODE&gt;spath&lt;/CODE&gt; command to parse it.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| spath input=Params
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it isn't, so that's not useful.  However, you should be able to use &lt;CODE&gt;extract&lt;/CODE&gt; without having to use a complex regex.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | extract pairdelim=";{}" kvdelim=":" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tested it with the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* | head 1 | eval _raw="{ field1 : Original;  media : MediaType;  post : mu}"  | extract pairdelim=";{}" kvdelim=":" | table field1 media post
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which outputs:&lt;/P&gt;

&lt;TABLE&gt;&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH&gt;field1&lt;/TH&gt;
&lt;TH&gt;media&lt;/TH&gt;
&lt;TH&gt;post&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Original&lt;/TD&gt;
&lt;TD&gt;MediaType&lt;/TD&gt;
&lt;TD&gt;mu&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;&lt;/TABLE&gt;

&lt;P&gt;This will be flexible to any kvpairs that happen to show up in the Params field.  (Note it'll get weird if the values themselves contain &lt;CODE&gt;{}:;&lt;/CODE&gt; as that'll be what it's looking for to separate kvpairs)&lt;/P&gt;</description>
      <pubDate>Thu, 26 Feb 2015 17:24:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-the-payload-inside-a-csv-log-to-run-a-stats-count/m-p/152011#M42605</guid>
      <dc:creator>emiller42</dc:creator>
      <dc:date>2015-02-26T17:24:00Z</dc:date>
    </item>
  </channel>
</rss>

