<?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 Why is Alert action not triggering when using real time? in Other Usage</title>
    <link>https://community.splunk.com/t5/Other-Usage/Why-is-Alert-action-not-triggering-when-using-real-time/m-p/655894#M1288</link>
    <description>&lt;P&gt;-I am running an alert which is not triggering email actions when using real-time option.&amp;nbsp; &amp;nbsp;The alert is used to&amp;nbsp; search for hosts which have not sent logs in the last 5 minutes.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-For example, I shut down a host for testing and wait 5 minutes. I then manually use the search string and specify time frame (e.g. last 15 minutes)- I am able to obtain results.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;However,&amp;nbsp;&amp;nbsp;even though the same search was configured in the form of an alert running in real time, it&amp;nbsp;produces no results nor does it trigger an email.&lt;/P&gt;
&lt;P&gt;Here is the search I am using:&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=* | stats max(_time) as latest by host | eval recent= if(latest &amp;gt; relative_time(now(),"-5m"),1,0). realLatest = strftime(latest, "%Y-%M-%D %H%M%S") | fields - latest | where recent = 0 | rename host AS Host, realLatest AS "Latest Timestamp" | table Host, "Latest Timestamp"&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;</description>
    <pubDate>Mon, 28 Aug 2023 18:53:21 GMT</pubDate>
    <dc:creator>theprophet01</dc:creator>
    <dc:date>2023-08-28T18:53:21Z</dc:date>
    <item>
      <title>Why is Alert action not triggering when using real time?</title>
      <link>https://community.splunk.com/t5/Other-Usage/Why-is-Alert-action-not-triggering-when-using-real-time/m-p/655894#M1288</link>
      <description>&lt;P&gt;-I am running an alert which is not triggering email actions when using real-time option.&amp;nbsp; &amp;nbsp;The alert is used to&amp;nbsp; search for hosts which have not sent logs in the last 5 minutes.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;-For example, I shut down a host for testing and wait 5 minutes. I then manually use the search string and specify time frame (e.g. last 15 minutes)- I am able to obtain results.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;However,&amp;nbsp;&amp;nbsp;even though the same search was configured in the form of an alert running in real time, it&amp;nbsp;produces no results nor does it trigger an email.&lt;/P&gt;
&lt;P&gt;Here is the search I am using:&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=* | stats max(_time) as latest by host | eval recent= if(latest &amp;gt; relative_time(now(),"-5m"),1,0). realLatest = strftime(latest, "%Y-%M-%D %H%M%S") | fields - latest | where recent = 0 | rename host AS Host, realLatest AS "Latest Timestamp" | table Host, "Latest Timestamp"&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;</description>
      <pubDate>Mon, 28 Aug 2023 18:53:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/Why-is-Alert-action-not-triggering-when-using-real-time/m-p/655894#M1288</guid>
      <dc:creator>theprophet01</dc:creator>
      <dc:date>2023-08-28T18:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Alert action not triggering when using real time?</title>
      <link>https://community.splunk.com/t5/Other-Usage/Why-is-Alert-action-not-triggering-when-using-real-time/m-p/655910#M1289</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/247101"&gt;@theprophet01&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;using a search like yours with Real-Time it isn't a good idea because you are using one CPU only for this search reducing the resources of your global Splunk infrastructure.&lt;/P&gt;&lt;P&gt;It's better to schedure a search e.g. every 5 minutes, so, when running is finished, the search releases the CPU for other jobs.&lt;/P&gt;&lt;P&gt;In addition, your search could be optimized to reduce the execution time and the CPU use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats max(_time) AS latest count BY host
| eval recent= if(latest &amp;gt; relative_time(now(),"-5m"),1,0). realLatest = strftime(latest, "%Y-%M-%D %H%M%S") 
| where recent = 0 
| rename host AS Host, realLatest AS "Latest Timestamp" 
| table Host, "Latest Timestamp"&lt;/LI-CODE&gt;&lt;P&gt;At least, using this search you find only the hosts that didn't send logs in the last 5 minutes, but that sent logs in the previous 10 minutes (using a timeframe of 15 minutes); if your host doesn't send logs for 15 minutes you loose this information.&lt;/P&gt;&lt;P&gt;The best approach is having a lookup containing all the hosts to monitor (called e.g. perimeter.csv) containing at least one column (host) and running a search like the following:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| tstats max(_time) AS latest count BY host
| append [ | inputlookup perimeter.csv | eval count=0 | fields host count ]
| stats max(_time) AS latest sum(count) AS total BY host
| where total = 0 
| rename host AS Host, realLatest AS "Latest Timestamp" 
| table Host, "Latest Timestamp"&lt;/LI-CODE&gt;&lt;P&gt;in this way you have to manage the lookup but you have a more affidable control.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 06:10:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/Why-is-Alert-action-not-triggering-when-using-real-time/m-p/655910#M1289</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-08-29T06:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Alert action not triggering when using real time?</title>
      <link>https://community.splunk.com/t5/Other-Usage/Why-is-Alert-action-not-triggering-when-using-real-time/m-p/655961#M1290</link>
      <description>&lt;P&gt;That worked perfect! I also used the 5 min scheduled search as suggested using a cron schedule. Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;you sir are indeed a legend!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 12:49:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Other-Usage/Why-is-Alert-action-not-triggering-when-using-real-time/m-p/655961#M1290</guid>
      <dc:creator>theprophet01</dc:creator>
      <dc:date>2023-08-29T12:49:15Z</dc:date>
    </item>
  </channel>
</rss>

