<?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: Alerting when consumer stopped in Alerting</title>
    <link>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456250#M11593</link>
    <description>&lt;P&gt;try adding a condition based on time as well. Please test it thoroughly&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="myindex" sourcetype="mysourcetype" (status="produced" OR status="consumed")
 |stats values(status) as status,dc(status) as count, latest(eval(if(status=="produced",_time,null()))) as time by id 
 |where count &amp;lt;2 AND isnotnull(mvfind(status,"produced")) AND (now()-time) &amp;gt; 10
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 17 May 2019 08:01:09 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2019-05-17T08:01:09Z</dc:date>
    <item>
      <title>Alerting when consumer stopped</title>
      <link>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456245#M11588</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I have an async producer/consumer each logging something like:&lt;/P&gt;

&lt;P&gt;producer:&lt;BR /&gt;
log.info("id=123, status=produced);&lt;/P&gt;

&lt;P&gt;consumer:&lt;BR /&gt;
log.info("id=123, status=consumed");&lt;/P&gt;

&lt;P&gt;where id is the transaction ID.&lt;/P&gt;

&lt;P&gt;I want to get alerted only when producer is producing and for some reason consumer stopped consuming.&lt;/P&gt;

&lt;P&gt;I did write something like:&lt;/P&gt;

&lt;P&gt;index="myindex"  sourcetype="mysourcetype" | transaction id startswith=(status="produced") endswith=(status="consumed")  keepevicted=true maxevents=10 | stats count by closed_txn &lt;/P&gt;

&lt;P&gt;Then I ran both producer and consumer simultaneously and observed Splunk showing 0 and 1 for closed_txn.&lt;/P&gt;

&lt;P&gt;My assumption is that I should see closed_txn as 1 as both consumer and producer are running.&lt;/P&gt;

&lt;P&gt;Later I killed the consumer and let the producer keep running.&lt;/P&gt;

&lt;P&gt;Still I get closed_txn showing up as 1 and 0 whereas I thought Splunk should only report 0 as the transaction failed as there is no log from consumer.&lt;/P&gt;

&lt;P&gt;I am not sure if I am doing it right.&lt;/P&gt;

&lt;P&gt;In summary I want to get alerted when there is production but no consumption.&lt;/P&gt;

&lt;P&gt;I don't want to get alerted when there is no production.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 00:27:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456245#M11588</guid>
      <dc:creator>Aravind_Sridhar</dc:creator>
      <dc:date>2019-05-16T00:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Alerting when consumer stopped</title>
      <link>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456246#M11589</link>
      <description>&lt;P&gt;@&lt;A href="mailto:Aravind_Sridharan@intuit.com"&gt;Aravind_Sridharan@intuit.com&lt;/A&gt; ,&lt;/P&gt;

&lt;P&gt;Try this and test against your requirement&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="myindex" sourcetype="mysourcetype" (status="produced" OR status="consumed")
|stats values(status) as status,dc(status) as count by id |where count &amp;lt;2 AND isnotnull(mvfind(status,"produced"))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alerts when there is only one status for a transaction which is &lt;CODE&gt;produced&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;You may change the &lt;CODE&gt;where&lt;/CODE&gt; condition  according to your final requirement&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 07:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456246#M11589</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-05-16T07:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Alerting when consumer stopped</title>
      <link>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456247#M11590</link>
      <description>&lt;P&gt;Hi @&lt;A href="mailto:Aravind_Sridharan@intuit.com"&gt;Aravind_Sridharan@intuit.com&lt;/A&gt;,&lt;/P&gt;

&lt;P&gt;Your assumptions are right about the &lt;CODE&gt;closed_txn&lt;/CODE&gt; as you can see here :&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/Transaction"&gt;https://docs.splunk.com/Documentation/Splunk/7.2.6/SearchReference/Transaction&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Your problem could be due to the search being too memory intensive, see bellow between the &lt;CODE&gt;**&lt;/CODE&gt; from the doc above : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;keepevicted
Syntax: keepevicted=&amp;lt;bool&amp;gt;
Description: Whether to output evicted transactions. Evicted transactions can be distinguished from non-evicted transactions by checking the value of the 'closed_txn' field. The 'closed_txn' field is set to '0', or false, for evicted transactions and '1', or true for non-evicted, or closed, transactions. The 'closed_txn' field is set to '1' if one of the following conditions is met: maxevents, maxpause, maxspan, startswith. For startswith, because the transaction command sees events in reverse time order, it closes a transaction when it satisfies the start condition. **If none of these conditions is specified, all transactions are output even though all transactions will have 'closed_txn' set to '0'. A transaction can also be evicted when the memory limitations are reached**.
Default: false or 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could use a more optimized way (processor-wise) to handle your query while avoiding transactions :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="myindex" sourcetype="mysourcetype" status="produced" OR status="consumed"
 |stats values(status) as status, dc(status) as count by id 
 |where count &amp;lt;2 AND status!="consumed"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 07:53:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456247#M11590</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-05-16T07:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Alerting when consumer stopped</title>
      <link>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456248#M11591</link>
      <description>&lt;P&gt;When I run this, I do see a few search results when consumer is not fast enough processing it. Is there a way to add delay say up to 5-10 seconds as sometimes I do see consumer getting messages after 5+ seconds?&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 16:51:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456248#M11591</guid>
      <dc:creator>Aravind_Sridhar</dc:creator>
      <dc:date>2019-05-16T16:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Alerting when consumer stopped</title>
      <link>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456249#M11592</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 16:52:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456249#M11592</guid>
      <dc:creator>Aravind_Sridhar</dc:creator>
      <dc:date>2019-05-16T16:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Alerting when consumer stopped</title>
      <link>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456250#M11593</link>
      <description>&lt;P&gt;try adding a condition based on time as well. Please test it thoroughly&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="myindex" sourcetype="mysourcetype" (status="produced" OR status="consumed")
 |stats values(status) as status,dc(status) as count, latest(eval(if(status=="produced",_time,null()))) as time by id 
 |where count &amp;lt;2 AND isnotnull(mvfind(status,"produced")) AND (now()-time) &amp;gt; 10
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 May 2019 08:01:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Alerting/Alerting-when-consumer-stopped/m-p/456250#M11593</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-05-17T08:01:09Z</dc:date>
    </item>
  </channel>
</rss>

