<?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 evaluate if a field is null or not null from JSON structured data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-if-a-field-is-null-or-not-null-from-JSON/m-p/317918#M95122</link>
    <description>&lt;P&gt;My data is structured into a JSON with a field inside a block that is as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{  "SomeField":"Value",
   "serviceInfoBlock":{"SomeOtherField":"Value",
                       "logID":"Value"}
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The LogID can be either null or have an actual value populated in it. I am trying to use eval to create a new field "isNull" that can tell me if the logID is null, or has a value in it.&lt;/P&gt;

&lt;P&gt;If I do &lt;CODE&gt;|eval isNull=if(serviceInfoBlock.logID==null, "True", "False")&lt;/CODE&gt; it creates the field but assigns every value to be false. &lt;BR /&gt;
If I do &lt;CODE&gt;|eval isNull=if(isnull(serviceInfoBlock.logID), "True", "False")&lt;/CODE&gt; it creates the field but assigns every value to be true.&lt;/P&gt;

&lt;P&gt;If in my intial search, however, I add in &lt;CODE&gt;serviceInfoBlock.logID=null&lt;/CODE&gt; or &lt;CODE&gt;serviceInfoBlock.logID!=null&lt;/CODE&gt; it properly filters my results.&lt;/P&gt;

&lt;P&gt;Why can I filter properly in the search, but not create a field of the same type of filtering through eval?&lt;/P&gt;</description>
    <pubDate>Fri, 02 Mar 2018 16:56:37 GMT</pubDate>
    <dc:creator>brajaram</dc:creator>
    <dc:date>2018-03-02T16:56:37Z</dc:date>
    <item>
      <title>How to evaluate if a field is null or not null from JSON structured data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-if-a-field-is-null-or-not-null-from-JSON/m-p/317918#M95122</link>
      <description>&lt;P&gt;My data is structured into a JSON with a field inside a block that is as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{  "SomeField":"Value",
   "serviceInfoBlock":{"SomeOtherField":"Value",
                       "logID":"Value"}
 }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The LogID can be either null or have an actual value populated in it. I am trying to use eval to create a new field "isNull" that can tell me if the logID is null, or has a value in it.&lt;/P&gt;

&lt;P&gt;If I do &lt;CODE&gt;|eval isNull=if(serviceInfoBlock.logID==null, "True", "False")&lt;/CODE&gt; it creates the field but assigns every value to be false. &lt;BR /&gt;
If I do &lt;CODE&gt;|eval isNull=if(isnull(serviceInfoBlock.logID), "True", "False")&lt;/CODE&gt; it creates the field but assigns every value to be true.&lt;/P&gt;

&lt;P&gt;If in my intial search, however, I add in &lt;CODE&gt;serviceInfoBlock.logID=null&lt;/CODE&gt; or &lt;CODE&gt;serviceInfoBlock.logID!=null&lt;/CODE&gt; it properly filters my results.&lt;/P&gt;

&lt;P&gt;Why can I filter properly in the search, but not create a field of the same type of filtering through eval?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 16:56:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-if-a-field-is-null-or-not-null-from-JSON/m-p/317918#M95122</guid>
      <dc:creator>brajaram</dc:creator>
      <dc:date>2018-03-02T16:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to evaluate if a field is null or not null from JSON structured data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-if-a-field-is-null-or-not-null-from-JSON/m-p/317919#M95123</link>
      <description>&lt;P&gt;The field names which contains non-alphanumeric characters (dot, dash etc), needs to be enclosed in single quotes, in the right side of the expression for eval and where command. So, following should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval isNull=if('serviceInfoBlock.logID'==null(), "True", "False")
|eval isNull=if(isnull('serviceInfoBlock.logID'), "True", "False")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the base search OR with &lt;CODE&gt;|search&lt;/CODE&gt; command, you don't need the field name to be enclosed within single quotes, hence it works.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 19:26:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-if-a-field-is-null-or-not-null-from-JSON/m-p/317919#M95123</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-03-02T19:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to evaluate if a field is null or not null from JSON structured data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-if-a-field-is-null-or-not-null-from-JSON/m-p/317920#M95124</link>
      <description>&lt;P&gt;Thanks! I had tried variations with quotation marks, didn't realize I needed single quotes to make it work.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 19:47:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-evaluate-if-a-field-is-null-or-not-null-from-JSON/m-p/317920#M95124</guid>
      <dc:creator>brajaram</dc:creator>
      <dc:date>2018-03-02T19:47:38Z</dc:date>
    </item>
  </channel>
</rss>

