<?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 to setup Splunk Alert when status not changed in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297296#M12007</link>
    <description>&lt;P&gt;Hi Amigo,&lt;/P&gt;

&lt;P&gt;I need to setup a Splunk alert when the status is not changed from "status = pending_app_gw." to "status = ACTIVE. with in 5-10 sec" max. if not changed to active it should alert.&lt;/P&gt;

&lt;P&gt;08.02.2017 07:25:26.280 | 344 | INFO | 10098094 | GW: session(90200371) status = INITIALIZING.&lt;BR /&gt;
08.02.2017 07:25:26.280 | 344 | INFO | 10098094 | GW: session(90200371) status = pending_app_gw.&lt;/P&gt;

&lt;P&gt;*****&lt;STRONG&gt;&lt;EM&gt;after restart of the application *&lt;/EM&gt;&lt;/STRONG&gt;******&lt;BR /&gt;
08.02.2017 08:20:36.618 | 1752 | INFO | 10098094 | GW: session(90200371) status = INITIALIZING.&lt;BR /&gt;
08.02.2017 08:20:36.618 | 1752 | INFO | 10098094 | GW: session(90200371) status = pending_app_gw.&lt;BR /&gt;
08.02.2017 08:20:36.706 | 5344 | INFO | 10098094 | GW: session(90200371) status = ACTIVE.&lt;/P&gt;

&lt;P&gt;I tried with the below query. but it is not working as expected.&lt;BR /&gt;
pending_app_gw sourcetype=sesionlog |rex "^[^(\n]*((?P\d+)"|join ses_id [ search sourcetype=oslog earliest=-10s latest=now "status = ACTIVE."]|table host ses_id&lt;/P&gt;

&lt;P&gt;Appreciate your help to setup the alert working properly.&lt;/P&gt;

&lt;P&gt;Thanks in Advance.&lt;/P&gt;

&lt;P&gt;Regards&lt;BR /&gt;
Babujlinuz &lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 12:50:59 GMT</pubDate>
    <dc:creator>babujlinuz</dc:creator>
    <dc:date>2020-09-29T12:50:59Z</dc:date>
    <item>
      <title>How to setup Splunk Alert when status not changed</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297296#M12007</link>
      <description>&lt;P&gt;Hi Amigo,&lt;/P&gt;

&lt;P&gt;I need to setup a Splunk alert when the status is not changed from "status = pending_app_gw." to "status = ACTIVE. with in 5-10 sec" max. if not changed to active it should alert.&lt;/P&gt;

&lt;P&gt;08.02.2017 07:25:26.280 | 344 | INFO | 10098094 | GW: session(90200371) status = INITIALIZING.&lt;BR /&gt;
08.02.2017 07:25:26.280 | 344 | INFO | 10098094 | GW: session(90200371) status = pending_app_gw.&lt;/P&gt;

&lt;P&gt;*****&lt;STRONG&gt;&lt;EM&gt;after restart of the application *&lt;/EM&gt;&lt;/STRONG&gt;******&lt;BR /&gt;
08.02.2017 08:20:36.618 | 1752 | INFO | 10098094 | GW: session(90200371) status = INITIALIZING.&lt;BR /&gt;
08.02.2017 08:20:36.618 | 1752 | INFO | 10098094 | GW: session(90200371) status = pending_app_gw.&lt;BR /&gt;
08.02.2017 08:20:36.706 | 5344 | INFO | 10098094 | GW: session(90200371) status = ACTIVE.&lt;/P&gt;

&lt;P&gt;I tried with the below query. but it is not working as expected.&lt;BR /&gt;
pending_app_gw sourcetype=sesionlog |rex "^[^(\n]*((?P\d+)"|join ses_id [ search sourcetype=oslog earliest=-10s latest=now "status = ACTIVE."]|table host ses_id&lt;/P&gt;

&lt;P&gt;Appreciate your help to setup the alert working properly.&lt;/P&gt;

&lt;P&gt;Thanks in Advance.&lt;/P&gt;

&lt;P&gt;Regards&lt;BR /&gt;
Babujlinuz &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297296#M12007</guid>
      <dc:creator>babujlinuz</dc:creator>
      <dc:date>2020-09-29T12:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to setup Splunk Alert when status not changed</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297297#M12008</link>
      <description>&lt;P&gt;Hi babujlinuz,&lt;BR /&gt;
Take a look here: &lt;A href="https://answers.splunk.com/answers/177265/how-to-configure-an-alert-for-when-a-given-event-i-1.html"&gt;https://answers.splunk.com/answers/177265/how-to-configure-an-alert-for-when-a-given-event-i-1.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 15:14:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297297#M12008</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-03-06T15:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to setup Splunk Alert when status not changed</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297298#M12009</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;(your base search) 
| table ses_id status 
| dedup ses_id 
| where status!="ACTIVE" 
| addinfo 
| where _time &amp;lt; info_max_time - 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically, any status that is not ="ACTIVE" as/of 10 seconds before the end of the search needs an alert.&lt;/P&gt;

&lt;P&gt;However, it seems like there ought to be identifying information about WHAT is running... the host or service name , so you need to add that into the code as appropriate. Let's assume that it was &lt;CODE&gt;appname&lt;/CODE&gt;.  It could just as well be &lt;CODE&gt;sourcetype&lt;/CODE&gt; or &lt;CODE&gt;host&lt;/CODE&gt; or whatever.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your base search) earliest=-1h latest=-10s 
| table  ses_id appname status 
| dedup ses_id appname 
| where status!="ACTIVE" 
| addinfo 
| where _time &amp;lt; info_max_time - 10
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 20:07:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297298#M12009</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-06T20:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to setup Splunk Alert when status not changed</title>
      <link>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297299#M12010</link>
      <description>&lt;P&gt;Since you do not have a unique transaction ID, you can make use of streamstats. First you would need to perform field extractions. Since &lt;CODE&gt;status&lt;/CODE&gt; is key value pain in your data, it should be automatically extracted as search time.&lt;BR /&gt;
You can use Pipe delimited Interactive Field Extraction in Splunk &lt;BR /&gt;
&lt;STRONG&gt;transforms.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sesionlog]
DELIMS = "|"
FIELDS = "field1","thread_id","log_level","trans_id","status_details"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Finally, for Session ID you can use regular expression based field extraction.&lt;BR /&gt;
&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sesionlog]
EXTRACT-session_id = ^[^\(\n]*\((?P&amp;lt;session_id&amp;gt;\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Finally try streamstats like following which resets counter every time after finding an Active status(there can be multiple options)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;YourIndexName&amp;gt; sourcetype=sesionlog status="pending_app_gw." OR status="ACTIVE."
| table _time session_id trans_id thread_id log_level status 
| reverse
| streamstats count current=f reset_after="("status==\"ACTIVE.\"")" 
| stats count as eventcount min(_time) as MinTime max(_time) as MaxTime values(status) as status values(count) as CountFlag by session_id trans_id
| search (eventcount=3 AND CountFlag=2 AND status="pending_app_gw." AND status="ACTIVE.") OR (eventcount=1 AND CountFlag=0 AND status="pending_app_gw." AND status!="ACTIVE.")
| eval OrphanedPendingStatusDuration=now()-MinTime
| rename MinTime as OrphanedPendingStatusTime
| fieldformat OrphanedPendingStatusTime=strftime(OrphanedPendingStatusTime,"%c")
| fieldformat MaxTime=strftime(MaxTime,"%c")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: Based on your data there might be other combinations as well. Like &lt;CODE&gt;(eventcount=2 AND CountFlag=1 AND status="pending_app_gw."  AND status="ACTIVE.")&lt;/CODE&gt; represents all expected Pending Status followed by Active Status.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 20:12:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/How-to-setup-Splunk-Alert-when-status-not-changed/m-p/297299#M12010</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-06T20:12:55Z</dc:date>
    </item>
  </channel>
</rss>

