<?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: Where command not filtering the data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521217#M146853</link>
    <description>&lt;P&gt;HI &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; :&lt;/P&gt;&lt;P&gt;Below is the log (redacted remaining lines):&lt;/P&gt;&lt;P&gt;timeStamp="2020/09/15 03:16:38.670 UTC" -- log="ERROR" -- threadId="" -- className="" -- handler=""&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-09-24 at 16.05.25.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/10960i60E4F47B52572FEE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2020-09-24 at 16.05.25.png" alt="Screenshot 2020-09-24 at 16.05.25.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The above is the log values I've.&lt;/P&gt;&lt;P&gt;I tried using rex to grep the log value, to make sure the log doesn't have any special characters but result was still the same.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Sep 2020 07:27:53 GMT</pubDate>
    <dc:creator>appu</dc:creator>
    <dc:date>2020-09-24T07:27:53Z</dc:date>
    <item>
      <title>Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521120#M146814</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi all ..I need a help on a query ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My query looks like this&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Index=* ......... | Eventstats count as total_count | where log!=error | eventstats count as success_count ....&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Issue is that , &lt;STRONG&gt;where&lt;/STRONG&gt; command doesn't filter properly .. and I get both total and success count as same even though there is &lt;EM&gt;&lt;STRONG&gt;log=error&lt;/STRONG&gt;&lt;/EM&gt; events(it doesn’t remove log=error events) ... I tried using&amp;nbsp;&lt;STRONG&gt;search&lt;/STRONG&gt; command ..tried&amp;nbsp;&lt;STRONG&gt;match&lt;/STRONG&gt; statement ... Still everything gives both total and success count as same . I’m finding this weird.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there anyway I can try to filter ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 17:28:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521120#M146814</guid>
      <dc:creator>appu</dc:creator>
      <dc:date>2020-09-23T17:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521122#M146816</link>
      <description>&lt;P&gt;Can you try&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;index=* ......... |&lt;STRONG&gt; search log!=error&lt;/STRONG&gt; | eventstats count as total_count | eventstats count as success_count ....&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------------------------&lt;BR /&gt;If this helps, your like will be appreciated. &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 17:35:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521122#M146816</guid>
      <dc:creator>vikramyadav</dc:creator>
      <dc:date>2020-09-23T17:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521153#M146826</link>
      <description>&lt;P&gt;Hi Vikram,&lt;/P&gt;&lt;P&gt;Thanks for the reply. Still total count will be same as success count. Isn't it ? (I tried, both values are same)&lt;/P&gt;&lt;P&gt;My intention is, I wanted to run a raw query, consider it as total count and then look for log!=error which is success count and find the failure count by subtracting success count from total count as i want to print all three values.&lt;/P&gt;&lt;P&gt;But, in my case that's not happening.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 20:08:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521153#M146826</guid>
      <dc:creator>appu</dc:creator>
      <dc:date>2020-09-23T20:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521158#M146828</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/226649"&gt;@appu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The where clause is used differently to the search clause, for example, consider these&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;1. where log!=error
2. where log!="error"
3. where !match(log, "error")
4. search log!=error
5. search log!=ERROR
6. search log=*error*&lt;/LI-CODE&gt;&lt;P&gt;1. Will compare whether the field 'log' and the field 'error' are not an exact match&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;Will compare whether the field 'log' does not match exactly the string "error"&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;Will compare whether the field 'log' contains the lower case string 'error"&amp;nbsp;&lt;/P&gt;&lt;P&gt;4-6. Using search is a simple string comparison and is case insensitive and wildcards are just * and it is always about comparing the log field against a string value, whether quoted or not.&lt;/P&gt;&lt;P&gt;So, if your log field CONTAINS the word "error" , then you should use example 3.&lt;/P&gt;&lt;P&gt;However, eventstats can be expensive as it is not aggregating data, so you can actually evaluate this in a better way&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* ......... 
| stats count as total_count sum(eval(if(match(log,"error"),0,1))) as success_count&lt;/LI-CODE&gt;&lt;P&gt;If you need to retain all the data, then you can use eventstats rather than stats, but using the sum(eval...) will give you both counts with a single operation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 22:01:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521158#M146828</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-09-23T22:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521164#M146830</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; :&lt;/P&gt;&lt;P&gt;Thanks for the reply and also for the interesting explanations. I never knew the behaviour of where command with and without quotes. thanks for that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is My actual query. I tried all the possibilities you mentioned except for point 3. But still not able to get the results. I'm not able to figure out what exactly is wrong.&lt;/P&gt;&lt;P&gt;I'm using eventstats so that I can pass the total count value to calculate percentage.&lt;/P&gt;&lt;P class="lia-align-left"&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;index=* ...&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;| eventstats dc(UserId) as totalUserId_Count dc(Users) as totalUsers_Count &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;| where log!="error"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;| eventstats dc(UserId) as successUserId_Count dc(Users) as successUsers_Count &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;| eval failUserId_count=(totalUserId_Count-successUserId_Count), failUsers_Count=(totalUsers_Count-successUsers_Count), success_percent = round ( ((successUserId_Count) / totalUserId_Count) * 100, 2)."%", &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;| dedup successUserId_Count failUserId_count successUsers_Count failUsers_Count success_percent &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;| table successUserId_Count failUserId_count successUsers_Count failUsers_Count success_percent&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 22:38:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521164#M146830</guid>
      <dc:creator>appu</dc:creator>
      <dc:date>2020-09-23T22:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521193#M146841</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/226649"&gt;@appu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are over complicating things.&amp;nbsp; All you need is a single stats statement, but your problem is that your field 'log' is probably not containing what you want.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* ...
| stats dc(UserId) as totalUserId_Count dc(Users) as totalUsers_Count dc(eval(if(log="error", null(), UserId)))) as successUserId_Count dc(eval(if(log="error", null(), Users))) successUsers_Count
| eval failUserId_count=(totalUserId_Count-successUserId_Count), failUsers_Count=(totalUsers_Count-successUsers_Count), success_percent = round ( ((successUserId_Count) / totalUserId_Count) * 100, 2)."%",
| table successUserId_Count failUserId_count successUsers_Count failUsers_Count success_percent&lt;/LI-CODE&gt;&lt;P&gt;You need to check exactly what your log field contains. Can you post an example of the log field&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 04:53:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521193#M146841</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-09-24T04:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521217#M146853</link>
      <description>&lt;P&gt;HI &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; :&lt;/P&gt;&lt;P&gt;Below is the log (redacted remaining lines):&lt;/P&gt;&lt;P&gt;timeStamp="2020/09/15 03:16:38.670 UTC" -- log="ERROR" -- threadId="" -- className="" -- handler=""&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-09-24 at 16.05.25.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/10960i60E4F47B52572FEE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2020-09-24 at 16.05.25.png" alt="Screenshot 2020-09-24 at 16.05.25.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The above is the log values I've.&lt;/P&gt;&lt;P&gt;I tried using rex to grep the log value, to make sure the log doesn't have any special characters but result was still the same.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 07:27:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521217#M146853</guid>
      <dc:creator>appu</dc:creator>
      <dc:date>2020-09-24T07:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521227#M146856</link>
      <description>&lt;P&gt;OK, so ERROR is in caps, which means&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* ...
| stats dc(UserId) as totalUserId_Count dc(Users) as totalUsers_Count dc(eval(if(log="ERROR", null(), UserId)))) as successUserId_Count dc(eval(if(log="ERROR", null(), Users))) successUsers_Count
| eval failUserId_count=(totalUserId_Count-successUserId_Count), failUsers_Count=(totalUsers_Count-successUsers_Count), success_percent = round ( ((successUserId_Count) / totalUserId_Count) * 100, 2)."%",
| table successUserId_Count failUserId_count successUsers_Count failUsers_Count success_percent&lt;/LI-CODE&gt;&lt;P&gt;you can see the if(log="ERROR"... there, but you could also do if(match(log,"ERROR"...&lt;/P&gt;&lt;P&gt;This should give you the results&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 08:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521227#M146856</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-09-24T08:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521228#M146857</link>
      <description>When you are writing:&lt;BR /&gt;where log != error&lt;BR /&gt;you are looking events which content of field log is not equal tuo content of field error.&lt;BR /&gt;With search you are looking where content of field log is not value "error".</description>
      <pubDate>Thu, 24 Sep 2020 08:43:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521228#M146857</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-09-24T08:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521231#M146858</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt; :&lt;/P&gt;&lt;P&gt;Yes, Thank you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 08:59:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521231#M146858</guid>
      <dc:creator>appu</dc:creator>
      <dc:date>2020-09-24T08:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Where command not filtering the data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521233#M146859</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt; :&lt;/P&gt;&lt;P&gt;I tried the above method with little tweak. Instead of calculating the success and then calculating failure, (sadly, it was not giving any results) so I went ahead and checked for failures and from that I calculated success count.&lt;/P&gt;&lt;P&gt;I interchanged null() and Users/UserId. And instead of success I made it as failUsers_Count and failUserId_Count. Which is now giving the required result. Now My only worry is that why it was not giving the result the other way. But, thank you so much for the guidance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;dc(eval(if(log="ERROR", UserId, null())))) as failUserId_Count dc(eval(if(log="ERROR", Users,  null()))) failUsers_Count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 09:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Where-command-not-filtering-the-data/m-p/521233#M146859</guid>
      <dc:creator>appu</dc:creator>
      <dc:date>2020-09-24T09:13:52Z</dc:date>
    </item>
  </channel>
</rss>

