<?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: Dynamically remove events based on field value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617764#M214690</link>
    <description>&lt;P&gt;Hey thanks for the reply. It's been a long day and I'm not sure I explained the question correctly. That being said, your solution will definitely work for this case. I will test as I think it might work in my case too.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that the ID field is dependent on not being excluded in some cases. For instance:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* (msg=x OR msg=y OR msg=z) (value=1 OR value=2 OR value=3) | list(_raw) AS events BY ID value msg &lt;/LI-CODE&gt;&lt;P&gt;When value=1, it's okay to exclude msg=y or msg=z, but when value !=1, I still want those values to be included because I might get events where msg=y and value=2.&lt;/P&gt;&lt;P&gt;Does that make sense? I essentially want something like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where msg!=x AND value==1&lt;/LI-CODE&gt;&lt;P&gt;Can you use logic in the where command like that - I don't know but will try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 22:29:45 GMT</pubDate>
    <dc:creator>es5</dc:creator>
    <dc:date>2022-10-19T22:29:45Z</dc:date>
    <item>
      <title>How to dynamically remove events based on field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617755#M214686</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;I have a search that's something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* ID=*  (value=1 OR value=2 OR value=3) | list(_raw) as events BY ID value msg | table ID value msg&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, I utilize a drilldown option that adds the chosen value into a new search. Basically:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* ID=* value=1 | table ID value msg&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The point is to group events into one list based on them having the same ID and a specific value. Now, when I click the drilldown sometimes the table will include fields of value=1 that contain a "msg" field that is irrelevant to the data I'm searching for.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to do something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* ID=* value=1 | table ID value msg | eval msg=if(msg==bad, "Remove From Table", msg)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for being vague, but I cannot post the actual searches. I hope this makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 22:49:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617755#M214686</guid>
      <dc:creator>es5</dc:creator>
      <dc:date>2022-10-20T22:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically remove events based on field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617762#M214689</link>
      <description>&lt;P&gt;You can either just include that in the search command, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* ID=* value=1 msg!="bad"
| table ID value msg

OR 
...
| where msg!="bad"&lt;/LI-CODE&gt;&lt;P&gt;Presumably you have tokens from the original panel where the drilldown is made, so your search is something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* ID=* value=$clicked_token_value$
| table ID value msg&lt;/LI-CODE&gt;&lt;P&gt;Maybe there is something in the clicked data that you can also use as a filter for msg?&lt;/P&gt;&lt;P&gt;Anyway, basic answer is just exclude from search with search or where commands&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 22:04:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617762#M214689</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-10-19T22:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically remove events based on field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617764#M214690</link>
      <description>&lt;P&gt;Hey thanks for the reply. It's been a long day and I'm not sure I explained the question correctly. That being said, your solution will definitely work for this case. I will test as I think it might work in my case too.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that the ID field is dependent on not being excluded in some cases. For instance:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* (msg=x OR msg=y OR msg=z) (value=1 OR value=2 OR value=3) | list(_raw) AS events BY ID value msg &lt;/LI-CODE&gt;&lt;P&gt;When value=1, it's okay to exclude msg=y or msg=z, but when value !=1, I still want those values to be included because I might get events where msg=y and value=2.&lt;/P&gt;&lt;P&gt;Does that make sense? I essentially want something like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where msg!=x AND value==1&lt;/LI-CODE&gt;&lt;P&gt;Can you use logic in the where command like that - I don't know but will try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 22:29:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617764#M214690</guid>
      <dc:creator>es5</dc:creator>
      <dc:date>2022-10-19T22:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically remove events based on field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617765#M214691</link>
      <description>&lt;P&gt;I'm not sure I get the requirements totally - and it's the start of my day&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt; but I'm only 2 coffees in&lt;/P&gt;&lt;P&gt;However, the 'where' clause is very powerful - you can use any kind of eval statement in there.&lt;/P&gt;&lt;P&gt;Note that when comparing strings in where clauses, you can't use wildcard, like in search, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where msg!="bad*"&lt;/LI-CODE&gt;&lt;P&gt;Instead you can use the match statement, which takes a regex, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where match(msg, "^bad$") AND value=1&lt;/LI-CODE&gt;&lt;P&gt;you can put all sorts of AND/OR and other eval logic in there&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 22:45:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617765#M214691</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-10-19T22:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically remove events based on field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617784#M214692</link>
      <description>&lt;P&gt;If you want to exclude value=1 and msg=y OR msg=z then you should try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| search NOT (value=1 AND msg IN ("y", "z"))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Oct 2022 03:29:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617784#M214692</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-10-20T03:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically remove events based on field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617881#M214741</link>
      <description>&lt;P&gt;No worries, the problem was with my communication not your understanding! Let me try to explain in a more digestible way.&lt;/P&gt;&lt;P&gt;I have a search that checks for specific commands. IE: I want it to return all information where value = 1, 2, 3&lt;/P&gt;&lt;P&gt;The search specifically looks for values that are 1, 2, or 3, and when it finds those values, they also contain the msg field which can contain x, y, or z. The problem is, if I were to code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where value==1 AND msg==x OR msg==y&lt;/LI-CODE&gt;&lt;P&gt;I'm excluding a large portion of the potential returned results of the search because now I'm only checking for value=1 and msg=x, y.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for the search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* (value=1 OR value=2 OR value=3) AND (msg=x OR msg=y OR msg=z) &lt;/LI-CODE&gt;&lt;P&gt;I want my drilldown to show me specifics for each value, essentially, but not to exclude from the original search the potential for different values to be returned with their respective msg. So, I need the search to dynamically understand that ONLY IF value=1, should it exclude msg=x, y. But, if value=2 the search should still return msg where msg ANY of x, y, z.&lt;/P&gt;&lt;P&gt;Programmatically it'd look like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(value==1):
exclude(x, y)
else:
include(x, y, z)&lt;/LI-CODE&gt;&lt;P&gt;Still not sure if that makes sense and I understand it's hard to conceptualize without the actual search, so I appreciate the help.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 15:37:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617881#M214741</guid>
      <dc:creator>es5</dc:creator>
      <dc:date>2022-10-20T15:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically remove events based on field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617919#M214754</link>
      <description>&lt;P&gt;OK, so your main search is&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* (value=1 OR value=2 OR value=3) AND (msg=x OR msg=y OR msg=z) &lt;/LI-CODE&gt;&lt;P&gt;then the drilldown search could be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* value=$value_token$ 
| where (value=1 AND msg=z) OR value!=1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;so, it's effectively adding the where filter to say&lt;/P&gt;&lt;P&gt;value=1 + msg=z (same as your exclude x,y)&lt;BR /&gt;OR value=2 or 3 (!=1)&lt;/P&gt;&lt;P&gt;There are other ways, which may be more optimal in that in your &amp;lt;drilldown&amp;gt; part of the dashboard, you could set more than just the clicked value. You could also set the msg constraints with &amp;lt;eval&amp;gt; statements, e.g. (untested)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;drilldown&amp;gt;
  &amp;lt;set token="value_token"&amp;gt;$row.value$&amp;lt;/set&amp;gt;
  &amp;lt;eval token="msg_token"&amp;gt;if($row.value$=1, "z", "x,y,z")&amp;lt;/eval&amp;gt;
&amp;lt;/drilldown&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and then the drilldown search will do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* sourcetype=* value=$value_token$ msg IN ($msg_token$)&lt;/LI-CODE&gt;&lt;P&gt;so, in the case&amp;nbsp; you click 1, the msg_token is set to z and for all other values, it will set x,y,z and that is used for the drilldown.&lt;/P&gt;&lt;P&gt;You could also make the first search a base search and the drilldown search use the base search and then you only need * as the non value=1 test, as the base search has already filtered x,y,z.&lt;/P&gt;&lt;P&gt;Note: I have assumed you are drilling down from a table, hence the $row.value$ token setting.&lt;/P&gt;&lt;P&gt;I hope this helps get you where you need to get.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 21:26:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/617919#M214754</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-10-20T21:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically remove events based on field value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/618145#M214840</link>
      <description>&lt;P&gt;Thanks for your replies. I will give this a try today and let you know how it turns out!&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 14:45:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-dynamically-remove-events-based-on-field-value/m-p/618145#M214840</guid>
      <dc:creator>es5</dc:creator>
      <dc:date>2022-10-24T14:45:46Z</dc:date>
    </item>
  </channel>
</rss>

