<?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 fillnull json value pair using spath or some other command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-fillnull-json-value-pair-using-spath-or-some-other/m-p/419259#M120540</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;&amp;lt;notification-list xmlns="http://www......./restful/schema/response"&amp;gt;
&amp;lt;added-instance preexisting="false"&amp;gt;
&amp;lt;alarm id="12fffffa1"&amp;gt;
&amp;lt;attribute id="0x10"&amp;gt;abc&amp;lt;/attribute&amp;gt;
&amp;lt;attribute id="0x11"&amp;gt;machinename&amp;lt;/attribute&amp;gt;
&amp;lt;attribute id="0x22"/&amp;gt;
/alarm&amp;gt;
&amp;lt;/added-instance&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above xml am storing as a json response in splunk and using spath to do further query. &lt;BR /&gt;
But now the issue is if you see the last attribute the 0x22 doesn't have a value pair for the key and then the issue happens with orderly showing the table. &lt;/P&gt;

&lt;P&gt;How to fill the value pair for that attribute with 0 value ?&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2019 13:08:51 GMT</pubDate>
    <dc:creator>surekhasplunk</dc:creator>
    <dc:date>2019-07-31T13:08:51Z</dc:date>
    <item>
      <title>how to fillnull json value pair using spath or some other command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-fillnull-json-value-pair-using-spath-or-some-other/m-p/419259#M120540</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;&amp;lt;notification-list xmlns="http://www......./restful/schema/response"&amp;gt;
&amp;lt;added-instance preexisting="false"&amp;gt;
&amp;lt;alarm id="12fffffa1"&amp;gt;
&amp;lt;attribute id="0x10"&amp;gt;abc&amp;lt;/attribute&amp;gt;
&amp;lt;attribute id="0x11"&amp;gt;machinename&amp;lt;/attribute&amp;gt;
&amp;lt;attribute id="0x22"/&amp;gt;
/alarm&amp;gt;
&amp;lt;/added-instance&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above xml am storing as a json response in splunk and using spath to do further query. &lt;BR /&gt;
But now the issue is if you see the last attribute the 0x22 doesn't have a value pair for the key and then the issue happens with orderly showing the table. &lt;/P&gt;

&lt;P&gt;How to fill the value pair for that attribute with 0 value ?&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 13:08:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-fillnull-json-value-pair-using-spath-or-some-other/m-p/419259#M120540</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2019-07-31T13:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to fillnull json value pair using spath or some other command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-fillnull-json-value-pair-using-spath-or-some-other/m-p/419260#M120541</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;You could try with rex instead of spath. Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | fields - _time
| eval myXML = "&amp;lt;notification-list xmlns=\"http://www......./restful/schema/response\"&amp;gt;
 &amp;lt;added-instance preexisting=\"false\"&amp;gt;
 &amp;lt;alarm id=\"12fffffa1\"&amp;gt;
 &amp;lt;attribute id=\"0x10\"&amp;gt;abc&amp;lt;/attribute&amp;gt;
 &amp;lt;attribute id=\"0x11\"&amp;gt;machinename&amp;lt;/attribute&amp;gt;
 &amp;lt;attribute id=\"0x22\"/&amp;gt;
 &amp;lt;/alarm&amp;gt;
 &amp;lt;/added-instance&amp;gt;"
| rex field=myXML max_match=0 "(?msi)(?&amp;lt;attribute_line&amp;gt;\&amp;lt;attribute id\=.+?$)"
| mvexpand attribute_line
| rex field=attribute_line "id=\"(?&amp;lt;id&amp;gt;[^\"]+)\"(\/)?\&amp;gt;(?&amp;lt;attribute&amp;gt;[^\&amp;lt;]+)?"
| fillnull value=NULL attribute
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Will produce something like the attached screenshot.&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7423i890ED4312C001E23/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
Hope that helps.&lt;/P&gt;

&lt;P&gt;Regards,&lt;BR /&gt;
J&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 14:15:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-fillnull-json-value-pair-using-spath-or-some-other/m-p/419260#M120541</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2019-07-31T14:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to fillnull json value pair using spath or some other command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-fillnull-json-value-pair-using-spath-or-some-other/m-p/419261#M120542</link>
      <description>&lt;P&gt;Hi @surekhasplunk, did this solve your problem? If so, please do not forget to accept the answer so that we can close the question and others can benefit from it.&lt;/P&gt;

&lt;P&gt;Thanks, J&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 11:08:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-fillnull-json-value-pair-using-spath-or-some-other/m-p/419261#M120542</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2019-08-08T11:08:43Z</dc:date>
    </item>
  </channel>
</rss>

