<?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: Part 2: How to extract a json portion of an event then use spath to extract key=value pairs in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67992#M16991</link>
    <description>&lt;P&gt;The following regex will work, if and only if, there is not any new line in the event:&lt;/P&gt;

&lt;P&gt;rex "&lt;TVSQUERY id="(?&amp;lt;id"&gt;[^&amp;gt;]+)&amp;gt;(?&lt;RESPONSE&gt;.+?)&lt;/RESPONSE&gt;"&lt;/TVSQUERY&gt;&lt;/P&gt;

&lt;P&gt;Therefore, I was able to make it work by trimming the event before the regular expression as follow:&lt;/P&gt;

&lt;P&gt;| rex field=_raw mode=sed "s/[\r\n]//g" &lt;BR /&gt;
| rex "&lt;TVSQUERY id="(?&amp;lt;id"&gt;[^&amp;gt;]+)&amp;gt;(?&lt;RESPONSE&gt;.+?)&lt;/RESPONSE&gt;"&lt;/TVSQUERY&gt;&lt;/P&gt;

&lt;P&gt;Then, the extracted field "response" can be processed by spath search command.&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
 Lp&lt;/P&gt;</description>
    <pubDate>Thu, 28 Mar 2013 12:38:07 GMT</pubDate>
    <dc:creator>lpolo</dc:creator>
    <dc:date>2013-03-28T12:38:07Z</dc:date>
    <item>
      <title>Part 2: How to extract a json portion of an event then use spath to extract key=value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67989#M16988</link>
      <description>&lt;P&gt;I have the following log event but I have not been able to use spath to extract the json key=value pairs if the json portion contains arrays. Event example:&lt;/P&gt;

&lt;P&gt;2013-03-12 10:37:10,205 &amp;lt;tvsquery id=58b6bf4d-948b-416b-8d17-cedcbc1059ec&amp;gt;{&lt;BR /&gt;
  "start" : 1,&lt;BR /&gt;
  "returned" : 1,&lt;BR /&gt;
  "count" : 1,&lt;BR /&gt;
  "entities" : [ {&lt;BR /&gt;
    "houses" : {&lt;BR /&gt;
      "callers" : "IM",&lt;BR /&gt;
      "placeid" : 5041447014850446107,&lt;BR /&gt;
      "number" : 14,&lt;BR /&gt;
      "sourceid" : 5625&lt;BR /&gt;
    },&lt;BR /&gt;
    "entitytype" : "house/street",&lt;BR /&gt;
    "title" : [ {&lt;BR /&gt;
      "default" : "No Place"&lt;BR /&gt;
    } ]&lt;BR /&gt;
  } ]&lt;BR /&gt;
}&amp;lt;/tvsquery&amp;gt;&lt;/P&gt;

&lt;P&gt;The following answer solved  the problem if the json protion does not contain any array:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://splunk-base.splunk.com/answers/79029/part-1-how-to-extract-a-json-portion-of-an-event-then-use-spath-to-extract-keyvalue-pairs"&gt;http://splunk-base.splunk.com/answers/79029/part-1-how-to-extract-a-json-portion-of-an-event-then-use-spath-to-extract-keyvalue-pairs&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I having a hard time to make it work.&lt;/P&gt;

&lt;P&gt;Any help please!&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Lp&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 15:43:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67989#M16988</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2013-03-20T15:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: Part 2: How to extract a json portion of an event then use spath to extract key=value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67990#M16989</link>
      <description>&lt;P&gt;Look at my answer in the original question you linked. It extracts everything, including values in arrays&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/spath.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2013 21:33:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67990#M16989</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-03-20T21:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Part 2: How to extract a json portion of an event then use spath to extract key=value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67991#M16990</link>
      <description>&lt;P&gt;I tried but It does not work. The regex does not return any value. what do you suggest?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Lp&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2013 12:03:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67991#M16990</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2013-03-21T12:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Part 2: How to extract a json portion of an event then use spath to extract key=value pairs</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67992#M16991</link>
      <description>&lt;P&gt;The following regex will work, if and only if, there is not any new line in the event:&lt;/P&gt;

&lt;P&gt;rex "&lt;TVSQUERY id="(?&amp;lt;id"&gt;[^&amp;gt;]+)&amp;gt;(?&lt;RESPONSE&gt;.+?)&lt;/RESPONSE&gt;"&lt;/TVSQUERY&gt;&lt;/P&gt;

&lt;P&gt;Therefore, I was able to make it work by trimming the event before the regular expression as follow:&lt;/P&gt;

&lt;P&gt;| rex field=_raw mode=sed "s/[\r\n]//g" &lt;BR /&gt;
| rex "&lt;TVSQUERY id="(?&amp;lt;id"&gt;[^&amp;gt;]+)&amp;gt;(?&lt;RESPONSE&gt;.+?)&lt;/RESPONSE&gt;"&lt;/TVSQUERY&gt;&lt;/P&gt;

&lt;P&gt;Then, the extracted field "response" can be processed by spath search command.&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
 Lp&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2013 12:38:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Part-2-How-to-extract-a-json-portion-of-an-event-then-use-spath/m-p/67992#M16991</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2013-03-28T12:38:07Z</dc:date>
    </item>
  </channel>
</rss>

