<?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 do you build an alert that triggers when a file is moved to a monitored folder? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459826#M129743</link>
    <description>&lt;P&gt;I'm trying to build an alert that triggers when a file is moved to an Error folder within the system we are monitoring.&lt;/P&gt;

&lt;P&gt;There are a few exceptions that I've needed to factor into my search some easy to figure out - others more difficult - one in particular.&lt;/P&gt;

&lt;P&gt;My current Search: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* sourcetype="FLO_LOG_FILES" DirPath=*\\Error* NOT 
 [| inputlookup ErrorFileExclude-Thresholds
  | eval path = if(len(FileName)&amp;gt;2,DirPath.FileName,"")
  | fields path]
| lookup IndexToClient index output ClientName Environment
| lookup ErrorFileExclude-Thresholds ClientName DirPath output FolderTimeTH FileCountTH
| fillnull value=0 FileCountTH
| fillnull value=1440 FolderTimeTH
| eval MinsDetected = round((now()-_time)/60,0)
| search MinsDetected &amp;gt; FolderTimeTH
| table host ClientName Environment source DirPath FolderTimeTH MinsDetected FileCountTH
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first NOT excludes particular file names - this part works well.&lt;/P&gt;

&lt;P&gt;The Bottom search should be excluding files based on an time threshold for that files folder.  This is where I'm having issues.&lt;/P&gt;

&lt;P&gt;If I update either side of the comparison with an actual number e.g. MinsDetected &amp;gt; 1440 OR FolderTimeTH &amp;lt; 1440 the filter works as expected, yet when I have the variable on each side - it's not working - struggling to understand why not.&lt;/P&gt;

&lt;P&gt;Based on the above search the last line in the below results should be the only result - yet it is not:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/6050i8EE9C863D32CD4F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Anyone able to provide assistance on this issue?&lt;/P&gt;</description>
    <pubDate>Tue, 06 Nov 2018 21:51:57 GMT</pubDate>
    <dc:creator>kozanic_FF</dc:creator>
    <dc:date>2018-11-06T21:51:57Z</dc:date>
    <item>
      <title>How do you build an alert that triggers when a file is moved to a monitored folder?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459826#M129743</link>
      <description>&lt;P&gt;I'm trying to build an alert that triggers when a file is moved to an Error folder within the system we are monitoring.&lt;/P&gt;

&lt;P&gt;There are a few exceptions that I've needed to factor into my search some easy to figure out - others more difficult - one in particular.&lt;/P&gt;

&lt;P&gt;My current Search: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* sourcetype="FLO_LOG_FILES" DirPath=*\\Error* NOT 
 [| inputlookup ErrorFileExclude-Thresholds
  | eval path = if(len(FileName)&amp;gt;2,DirPath.FileName,"")
  | fields path]
| lookup IndexToClient index output ClientName Environment
| lookup ErrorFileExclude-Thresholds ClientName DirPath output FolderTimeTH FileCountTH
| fillnull value=0 FileCountTH
| fillnull value=1440 FolderTimeTH
| eval MinsDetected = round((now()-_time)/60,0)
| search MinsDetected &amp;gt; FolderTimeTH
| table host ClientName Environment source DirPath FolderTimeTH MinsDetected FileCountTH
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first NOT excludes particular file names - this part works well.&lt;/P&gt;

&lt;P&gt;The Bottom search should be excluding files based on an time threshold for that files folder.  This is where I'm having issues.&lt;/P&gt;

&lt;P&gt;If I update either side of the comparison with an actual number e.g. MinsDetected &amp;gt; 1440 OR FolderTimeTH &amp;lt; 1440 the filter works as expected, yet when I have the variable on each side - it's not working - struggling to understand why not.&lt;/P&gt;

&lt;P&gt;Based on the above search the last line in the below results should be the only result - yet it is not:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/6050i8EE9C863D32CD4F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Anyone able to provide assistance on this issue?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 21:51:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459826#M129743</guid>
      <dc:creator>kozanic_FF</dc:creator>
      <dc:date>2018-11-06T21:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do you build an alert that triggers when a file is moved to a monitored folder?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459827#M129744</link>
      <description>&lt;P&gt;That's the nature of &lt;CODE&gt;search&lt;/CODE&gt; - it doesn't support fields compared to fields.  Try &lt;CODE&gt;where&lt;/CODE&gt;, instead.  It should to the job.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 00:47:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459827#M129744</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-11-07T00:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do you build an alert that triggers when a file is moved to a monitored folder?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459828#M129745</link>
      <description>&lt;P&gt;Thanks for the response Rich, unfortunately I need to use the where clause for another filter.&lt;BR /&gt;
I have tried using where to combine both this other filter with the one I'm having issues with - but getting similar results.&lt;/P&gt;

&lt;P&gt;I have come up with a work around however:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval AlertCheck = if(MinsDetected&amp;lt;FolderTimeTH,"True","False")
| search AlertCheck = True
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Nov 2018 03:17:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459828#M129745</guid>
      <dc:creator>kozanic_FF</dc:creator>
      <dc:date>2018-11-07T03:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do you build an alert that triggers when a file is moved to a monitored folder?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459829#M129746</link>
      <description>&lt;P&gt;You can have more than one &lt;CODE&gt;where&lt;/CODE&gt; clause.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 12:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459829#M129746</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-11-07T12:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do you build an alert that triggers when a file is moved to a monitored folder?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459830#M129747</link>
      <description>&lt;P&gt;Understand that - but was struggling to get the result I was after&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 20:50:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459830#M129747</guid>
      <dc:creator>kozanic_FF</dc:creator>
      <dc:date>2018-11-07T20:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do you build an alert that triggers when a file is moved to a monitored folder?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459831#M129748</link>
      <description>&lt;P&gt;Managed to figure out a way to get what I needed as mentioned above - full solution for anyone interested below: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* sourcetype="FLO_LOG_FILES" DirPath=*\\Error* NOT 
 [| inputlookup ErrorFileExclude-Thresholds
  | fillnull value=0 FileName_DayTmp
  | fillnull value=0 FileName
  | eval FileName=if(len(FileName_DayTmp)&amp;gt;1,FileName_DayTmp,FileName)
  | eval path = if(len(FileName)&amp;gt;1,DirPath.FileName,"")
  | fields path]
| lookup IndexToClient index output ClientName Environment
| lookup ErrorFileExclude-Thresholds ClientName DirPath output FolderTimeTH_DayTmp FolderTimeTH FileCountTH_DayTmp FileCountTH
| fillnull value=0 FileCountTH
| fillnull value=1440 FolderTimeTH
| fillnull value=0 FileCountTH_DayTmp
| fillnull value=0 FolderTimeTH_DayTmp
| eval FileCountTH=if(FileCountTH_DayTmp!=0,FileCountTH_DayTmp,FileCountTH)
| eval FolderTimeTH=if(FolderTimeTH_DayTmp!=0,FolderTimeTH_DayTmp,FolderTimeTH)
| eval MinsDetected = round((now()-_time)/60,0)
| eval AlertCheck = if(MinsDetected&amp;lt;FolderTimeTH,"True","False")
| search AlertCheck = True
| stats count as NumFiles by index host ClientName Environment source DirPath FileCountTH
| where NumFiles &amp;gt; FileCountTH
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search allows me to monitor a set of folders named "ERROR" and alert based on the below:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;File name is not on the exclusion list&lt;/LI&gt;
&lt;LI&gt;Time since detected for the Folder instance is less than the threshold&lt;/LI&gt;
&lt;LI&gt;Total count of files is less than the threshold for the given folder instance&lt;/LI&gt;
&lt;LI&gt;There is an option on both Time and Count thresholds to have fixed and DayTemp Threshold - lookup file is refreshed daily to clear the temp values&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 08 Nov 2018 21:50:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459831#M129748</guid>
      <dc:creator>kozanic_FF</dc:creator>
      <dc:date>2018-11-08T21:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do you build an alert that triggers when a file is moved to a monitored folder?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459832#M129749</link>
      <description>&lt;P&gt;@kozanic_FF If your problem is resolved, please accept an answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 12:14:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459832#M129749</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-11-09T12:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do you build an alert that triggers when a file is moved to a monitored folder?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459833#M129750</link>
      <description>&lt;P&gt;Hi RIch,&lt;/P&gt;

&lt;P&gt;I just had to wait until my answer was posted before I could set as accepted answer - I don't have enough karma points yet for my posts to appear straight away &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Nov 2018 21:00:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-build-an-alert-that-triggers-when-a-file-is-moved-to/m-p/459833#M129750</guid>
      <dc:creator>kozanic_FF</dc:creator>
      <dc:date>2018-11-11T21:00:12Z</dc:date>
    </item>
  </channel>
</rss>

