<?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: How do I use IF / THEN / AND in logic in a search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293039#M88450</link>
    <description>&lt;P&gt;Hi there @tmarlette&lt;/P&gt;

&lt;P&gt;Try something like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nix sourcetype=df host=myHost10 * OR host=myHost20* 
 | stats first(PercentUsedSpace) as pctUsed latest(Avail) as Avail by host, Filesystem, filesystem_type, Size, Used, MountedOn 
 | eval condition=case(host="host10*" AND MountedOn="/boot" AND pctUsed&amp;gt; 90, "1", machine="host20*" AND MountedOn="/boot" AND pctUsed &amp;gt; 95, "1", 1==1, "0")
 | sort - pctUsed 
 | where condition=="1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2017 17:30:34 GMT</pubDate>
    <dc:creator>alemarzu</dc:creator>
    <dc:date>2017-08-17T17:30:34Z</dc:date>
    <item>
      <title>How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293036#M88447</link>
      <description>&lt;P&gt;I'm trying to create some logic within my search, and it requires some IF THEN AND logic, which I know Splunk has the capability to do, but I don't know how to make it work the way I'm needing it. &lt;/P&gt;

&lt;P&gt;I have 2 different types of machines I'm searching, and I'm trying to alert on two distinct values. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;example&lt;/STRONG&gt;:  if machines named host10* have a mount with mount=/boot, AND have drive space over 90% then alert, AND if machines named host20* have a mount with mount=/boot AND drive space over 95% alert.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Working Query:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nix sourcetype=df host=myHost10 * OR host=myHost20* 
| stats first(PercentUsedSpace) as pctUsed latest(Avail) as Avail by host, Filesystem, filesystem_type, Size, Used, MountedOn 
| where pctUsed &amp;gt; 90
| sort - pctUsed 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I thought about using &lt;CODE&gt;|eval field=if(coalesce...)&lt;/CODE&gt;  but I don't think it fits my needs here, as both host types will have a value, it's just that the value needs to be filtered differently based upon the system type. maybe a subsearch? &lt;/P&gt;

&lt;P&gt;Any help would be appreciated. &lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:03:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293036#M88447</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2017-08-17T17:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293037#M88448</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=nix sourcetype=df host=myHost10 * OR host=myHost20* 
 | stats first(PercentUsedSpace) as pctUsed latest(Avail) as Avail by host, Filesystem, filesystem_type, Size, Used, MountedOn 
 | where (like(host,"myHost10%) AND pctUsed &amp;gt; 90) OR (like(host,"myHost20%) AND pctUsed &amp;gt; 95) 
 | sort - pctUsed 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:24:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293037#M88448</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-17T17:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293038#M88449</link>
      <description>&lt;P&gt;Try this query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=nix sourcetype=df (host=myHost10 * OR host=myHost20*) mount="/boot"
 | stats first(PercentUsedSpace) as pctUsed latest(Avail) as Avail by host, Filesystem, filesystem_type, Size, Used, MountedOn 
 | search (host=myHost10* pctUsed &amp;gt; 90) OR (host=myhost20* pctUsed&amp;gt;95)
 | sort - pctUsed
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:26:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293038#M88449</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-08-17T17:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293039#M88450</link>
      <description>&lt;P&gt;Hi there @tmarlette&lt;/P&gt;

&lt;P&gt;Try something like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nix sourcetype=df host=myHost10 * OR host=myHost20* 
 | stats first(PercentUsedSpace) as pctUsed latest(Avail) as Avail by host, Filesystem, filesystem_type, Size, Used, MountedOn 
 | eval condition=case(host="host10*" AND MountedOn="/boot" AND pctUsed&amp;gt; 90, "1", machine="host20*" AND MountedOn="/boot" AND pctUsed &amp;gt; 95, "1", 1==1, "0")
 | sort - pctUsed 
 | where condition=="1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:30:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293039#M88450</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2017-08-17T17:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293040#M88451</link>
      <description>&lt;P&gt;This seems so close. I just have to choose a mount on my linux systems, otherwise the data is pointless. This is what I have&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=nix sourcetype=df host=myHost10 * OR host=myHost20* 
 | stats first(PercentUsedSpace) as pctUsed latest(Avail) as Avail by host, Filesystem, filesystem_type, Size, Used, MountedOn 
| where (like(MountedOn,"%") AND pctUsed &amp;gt; 90) OR (like(MountedOn,"home/work%") AND pctUsed &amp;gt; 95)
 | sort - pctUsed 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;it's showing me weird results though. It's only showing me the machines that have 'home/work' mount ABOVE 90%. &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Update, the last statement was my own stupidity, please ignore that. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; It's just not filtering out the &amp;gt;95%. 
I think my filter is too vauge. &lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293040#M88451</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2017-08-17T17:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293041#M88452</link>
      <description>&lt;P&gt;This would work, if I only had to check the /boot mount, but I need to show the results of all other mounts on the system as well. =( &lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:51:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293041#M88452</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2017-08-17T17:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293042#M88453</link>
      <description>&lt;P&gt;So this is my filter now, I hope this explains what I'm trying to better:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index=nix sourcetype=df host=myHost10 * OR host=myHost20*    | stats first(PercentUsedSpace) as pctUsed latest(Avail) as Avail by host, Filesystem, filesystem_type, Size, Used, MountedOn  | where (like(MountedOn,"%") AND pctUsed &amp;gt; 50 AND MountedOn!="/home/work*") OR (like(MountedOn,"home/work%") AND pctUsed &amp;gt; 95)   | sort - pctUsed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm looking for all mounts above 50%, and then any &lt;CODE&gt;/home/work&lt;/CODE&gt; mounts that are above 95%, but I need them all displayed in a single table. The above query is still returning results with the /home/work below 95%. &lt;/P&gt;

&lt;P&gt;here is an image &lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 18:16:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293042#M88453</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2017-08-17T18:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293043#M88454</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nix sourcetype=df host=myHost10* OR host=myHost20*    | stats first(PercentUsedSpace) as pctUsed latest(Avail) as Avail by host, Filesystem, filesystem_type, Size, Used, MountedOn  | where (like(MountedOn,"home/work%") AND pctUsed &amp;gt; 95) OR   (NOT like(MountedOn,"home/work%") AND pctUsed &amp;gt; 50 ) | sort - pctUsed
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 18:40:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293043#M88454</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-17T18:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293044#M88455</link>
      <description>&lt;P&gt;still got the same result set. =( &lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 18:45:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293044#M88455</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2017-08-17T18:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use IF / THEN / AND in logic in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293045#M88456</link>
      <description>&lt;P&gt;I tried all of these, but alas... there was no success. I couldn't get the filter to populate all the results I needed. In the end I simply broke this into two alerts, 1 with filters around the mount and the pctUsed, and the other around everything EXCEPT that mount, but still with the pctUsed. &lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 22:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-IF-THEN-AND-in-logic-in-a-search/m-p/293045#M88456</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2017-09-05T22:10:02Z</dc:date>
    </item>
  </channel>
</rss>

