<?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 Difference between NOT and isnotnull in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389902#M190779</link>
    <description>&lt;P&gt;First of all, I'm a noob with Splunk and I started doing the fundamentals training.&lt;/P&gt;

&lt;P&gt;I'm at the logical operators module, and the following question arise from there.&lt;/P&gt;

&lt;P&gt;I have http request events that I want to filter out based on whether or not a request header key exists, in my case &lt;STRONG&gt;request.headers.bot&lt;/STRONG&gt;. The value of this field does not matter. This field only exists for requests flagged as bots. Regular requests will not have this field.&lt;/P&gt;

&lt;P&gt;event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  id: 123
  request: {
    headers: {
      cookie: "key=value; something=else;"
      user-agent: "Mozilla/5.0"
      bot: "yes"
    }
    path: "/"
  }
  time: 2019-07-16T18:08:59.980Z
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so, I'm running a search query to find out how many events are &lt;EM&gt;not bots&lt;/EM&gt;:&lt;/P&gt;

&lt;P&gt;before the training I had something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;request.path="/" | where isnull('request.headers.bot')
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but, while doing the training, I found out you could also do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;request.path="/" NOT request.headers.bot="*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;according to the training video, &lt;EM&gt;NOT&lt;/EM&gt;  returns events where the field does not exist or does not have the value specified&lt;/P&gt;

&lt;P&gt;However, for the same period of time, I'm getting different results:&lt;BR /&gt;
total events: 4000&lt;BR /&gt;
isnull: 3778&lt;BR /&gt;
not:  3798&lt;/P&gt;

&lt;P&gt;shouldn't both queries return the same events?&lt;/P&gt;

&lt;P&gt;also, is there a query that I can use to find the missing 20 events between the first and second query?&lt;/P&gt;

&lt;P&gt;thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jul 2019 19:23:42 GMT</pubDate>
    <dc:creator>rockosmodernlif</dc:creator>
    <dc:date>2019-07-16T19:23:42Z</dc:date>
    <item>
      <title>Difference between NOT and isnotnull</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389902#M190779</link>
      <description>&lt;P&gt;First of all, I'm a noob with Splunk and I started doing the fundamentals training.&lt;/P&gt;

&lt;P&gt;I'm at the logical operators module, and the following question arise from there.&lt;/P&gt;

&lt;P&gt;I have http request events that I want to filter out based on whether or not a request header key exists, in my case &lt;STRONG&gt;request.headers.bot&lt;/STRONG&gt;. The value of this field does not matter. This field only exists for requests flagged as bots. Regular requests will not have this field.&lt;/P&gt;

&lt;P&gt;event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  id: 123
  request: {
    headers: {
      cookie: "key=value; something=else;"
      user-agent: "Mozilla/5.0"
      bot: "yes"
    }
    path: "/"
  }
  time: 2019-07-16T18:08:59.980Z
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so, I'm running a search query to find out how many events are &lt;EM&gt;not bots&lt;/EM&gt;:&lt;/P&gt;

&lt;P&gt;before the training I had something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;request.path="/" | where isnull('request.headers.bot')
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but, while doing the training, I found out you could also do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;request.path="/" NOT request.headers.bot="*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;according to the training video, &lt;EM&gt;NOT&lt;/EM&gt;  returns events where the field does not exist or does not have the value specified&lt;/P&gt;

&lt;P&gt;However, for the same period of time, I'm getting different results:&lt;BR /&gt;
total events: 4000&lt;BR /&gt;
isnull: 3778&lt;BR /&gt;
not:  3798&lt;/P&gt;

&lt;P&gt;shouldn't both queries return the same events?&lt;/P&gt;

&lt;P&gt;also, is there a query that I can use to find the missing 20 events between the first and second query?&lt;/P&gt;

&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 19:23:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389902#M190779</guid>
      <dc:creator>rockosmodernlif</dc:creator>
      <dc:date>2019-07-16T19:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between NOT and isnotnull</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389903#M190780</link>
      <description>&lt;P&gt;No, they should not produce the same events. A bit of background,            &lt;CODE&gt;!=&lt;/CODE&gt; excludes null events (e.g.             &lt;CODE&gt;myfield!="asdf"&lt;/CODE&gt; is going to also discard null events), where              &lt;CODE&gt;NOT&lt;/CODE&gt; does not do this, it keeps the null events (e.g.             &lt;CODE&gt;NOT myfield="asdf"&lt;/CODE&gt;). It's poorly designed in my opinion and very dangerous; I had live dashboards for OVER A YEAR that were misrepresenting data because I was using != and did not want events with null values for a specific field discarded.&lt;/P&gt;

&lt;P&gt;So, more relevant, there is a difference between             &lt;CODE&gt;where&lt;/CODE&gt; and             &lt;CODE&gt;search&lt;/CODE&gt;.             &lt;CODE&gt;search myfield="*"&lt;/CODE&gt; is going to search for everything, whereas             &lt;CODE&gt;where myfield="*"&lt;/CODE&gt; is going to look for the literal *&lt;/P&gt;

&lt;P&gt;So assuming this is in a where clause, your second statement is just going to display all your results (assuming request.headers.bot is never a literal &lt;EM&gt;) whereas the first statement is going to correctly only display null. You should be able to do either           ```where NOT request.headers.bot=&lt;/EM&gt;&lt;CODE&gt;,&lt;/CODE&gt;where isnull(request.headers.bot)&lt;CODE&gt;,&lt;/CODE&gt;search isnull(request.headers.bot)&lt;CODE&gt;,&lt;/CODE&gt;search request.headers.bot!="&lt;EM&gt;"&lt;CODE&gt;, or&lt;/CODE&gt;search NOT request.headers.bot="&lt;/EM&gt;"``` (I believe)&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 23:38:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389903#M190780</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2019-07-16T23:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between NOT and isnotnull</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389904#M190781</link>
      <description>&lt;P&gt;One more thing - null is different from an empty string&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 23:46:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389904#M190781</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2019-07-16T23:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between NOT and isnotnull</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389905#M190782</link>
      <description>&lt;P&gt;tl;dr remove your quotes around the *&lt;/P&gt;

&lt;P&gt;sorry for the essay&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 23:53:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389905#M190782</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2019-07-16T23:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between NOT and isnotnull</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389906#M190783</link>
      <description>&lt;P&gt;Just as addition to this answer here is the docs link &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Search/NOTexpressions"&gt;https://docs.splunk.com/Documentation/Splunk/latest/Search/NOTexpressions&lt;/A&gt; with some good examples. &lt;/P&gt;

&lt;P&gt;And regarding the &lt;CODE&gt;search&lt;/CODE&gt; vs &lt;CODE&gt;where&lt;/CODE&gt; use &lt;CODE&gt;search&lt;/CODE&gt; if you want to search (HaHA) for a field value and use &lt;CODE&gt;where&lt;/CODE&gt; if you want to compare two fields or use &lt;CODE&gt;eval()&lt;/CODE&gt; functions on a field, see the docs &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/search#Comparing_two_fields"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/search#Comparing_two_fields&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 01:00:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Difference-between-NOT-and-isnotnull/m-p/389906#M190783</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2019-07-17T01:00:05Z</dc:date>
    </item>
  </channel>
</rss>

