<?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: Unable to extract all keys. in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351106#M42403</link>
    <description>&lt;P&gt;@sagar1905, you should be using &lt;CODE&gt;spath&lt;/CODE&gt; command to parse and extract JSON data. Try the following run anywhere search based on your data. As per your data BODY should show up during field discovery with the complete JSON data. If not you might have to create a regular expression to extract complete JSON data to a field first using rex command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval BODY="{\"key\":{\"key1\":\"value1\",\"key2\":\"value2\",\"dateAndTimeTransmission\":\"2017-12-19T19:33:54.000Z\",\"key3\":\"value3\",\"key4\":\"value4\",\"key5\":\"value5\",\"key6\":\"value6\",\"key\":2,\"key\":{\"key7\":\"value7\",\"key8\":\"value8\",\"key9\":\"value9\"},\"key\":{\"key\":[{\"key10\":\"value10\",\"key11\":\"value12\",\"key13\":\"value13\"},{\"key14\":\"value14\",\"key\":\"value\",\"key\":\"value\"}]},\"key\":\"value\",\"key\":\"value\"}}"
| spath input=BODY
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Refer to spath documentation for details: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Dec 2017 02:29:16 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-12-21T02:29:16Z</dc:date>
    <item>
      <title>Unable to extract all keys.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351105#M42402</link>
      <description>&lt;P&gt;I've a log to extract key value pairs from but I'm unable to extract all of them&lt;/P&gt;

&lt;P&gt;Sample log:&lt;BR /&gt;
2017-12-19 19:33:55,848 LL="DEBUG" CR="abq_asdaasd_adasdq_DAS" RE="abd" DE="abc" TR="tomcat-http--41" LN="xyz"  TYPE="IN-RESPONSE" BODY="{"key":{"key1":"value1","key2":"value2","dateAndTimeTransmission":"2017-12-19T19:33:54.000Z","key3":"value3","key4":"value4","key5":"value5","key6":"value6","key":2,"key":{"key7":"value7","key8":"value8","key9":"value9"},"key":{"key":[{"key10":"value10","key11":"value12","key13":"value13"},{"key14":"value14","key":"value","key":"value"}]},"key":"value","key":"value"}}"&lt;/P&gt;

&lt;P&gt;I'm using the query ----- &amp;gt;  index=xyz (  $searchKey$ ) | extract pairdelim="," kvdelim=":" | dedup key     ------ then followed by putting the value in the table.&lt;/P&gt;

&lt;P&gt;I require key10,value10  and key11,value11   I'm able to extract key11,value11 but my query is not extracting key10,value10 .. maybe due to the [{&lt;/P&gt;

&lt;P&gt;Can someone please help?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:19:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351105#M42402</guid>
      <dc:creator>sagar1905</dc:creator>
      <dc:date>2020-09-29T17:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to extract all keys.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351106#M42403</link>
      <description>&lt;P&gt;@sagar1905, you should be using &lt;CODE&gt;spath&lt;/CODE&gt; command to parse and extract JSON data. Try the following run anywhere search based on your data. As per your data BODY should show up during field discovery with the complete JSON data. If not you might have to create a regular expression to extract complete JSON data to a field first using rex command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval BODY="{\"key\":{\"key1\":\"value1\",\"key2\":\"value2\",\"dateAndTimeTransmission\":\"2017-12-19T19:33:54.000Z\",\"key3\":\"value3\",\"key4\":\"value4\",\"key5\":\"value5\",\"key6\":\"value6\",\"key\":2,\"key\":{\"key7\":\"value7\",\"key8\":\"value8\",\"key9\":\"value9\"},\"key\":{\"key\":[{\"key10\":\"value10\",\"key11\":\"value12\",\"key13\":\"value13\"},{\"key14\":\"value14\",\"key\":\"value\",\"key\":\"value\"}]},\"key\":\"value\",\"key\":\"value\"}}"
| spath input=BODY
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Refer to spath documentation for details: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2017 02:29:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351106#M42403</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-21T02:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to extract all keys.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351107#M42404</link>
      <description>&lt;P&gt;The keys are fixed but the values aren't, will the above query still work? And the keys also get changed sometimes, is there a general way to extract this? &lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2017 03:06:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351107#M42404</guid>
      <dc:creator>sagar1905</dc:creator>
      <dc:date>2017-12-22T03:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to extract all keys.</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351108#M42405</link>
      <description>&lt;P&gt;@sagar1905, yes it should work. &lt;CODE&gt;Spath&lt;/CODE&gt; command is used to traverse XML and JSON to extract Key Value pairs. Do check the command reference. Instead of first two commands i.e. &lt;CODE&gt;| makeresults and | eval BODY=...&lt;/CODE&gt; , you can put your Base search to extract the JSON data field i.e. BODY as per your question an then feed the same to spath command to get the extracted fields.&lt;/P&gt;

&lt;P&gt;Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Dec 2017 04:59:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Unable-to-extract-all-keys/m-p/351108#M42405</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-29T04:59:09Z</dc:date>
    </item>
  </channel>
</rss>

