<?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: Is it possible to do a delta grouped by a field in a search to find a missing sequence? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-do-a-delta-grouped-by-a-field-in-a-search-to/m-p/251151#M75025</link>
    <description>&lt;P&gt;How about you use &lt;CODE&gt;autoregress&lt;/CODE&gt; which will be able to look at previous event something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base query to return all the events
| sort queueName, seqId
| autoregress queueName as oldQ p=1
| autoregress seqId as oldSeq p=1
| eval flag=if( ( queueName=oldQ ) AND ( seqId != (oldSeq +1)), 1, 0)
| table queueName, seqId, oldSeqId, flag
| where flag=1
| fields -flag
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can alternatively tweak the if condition of &lt;CODE&gt;( seqId != (oldSeq +1))&lt;/CODE&gt; to something like &lt;CODE&gt;( seqId - oldSeq &amp;gt; 1)&lt;/CODE&gt; or whichever way you feel shall better represent your case.&lt;/P&gt;

&lt;P&gt;Also if you feel sorting on &lt;CODE&gt;_time&lt;/CODE&gt; will also help put the sequences in a better order than already done by &lt;CODE&gt;| sort queueName, seqId&lt;/CODE&gt; the try to combine &lt;CODE&gt;_time&lt;/CODE&gt; in there to make it &lt;CODE&gt;| sort queueName, seqId, _time&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Nov 2016 22:40:03 GMT</pubDate>
    <dc:creator>gokadroid</dc:creator>
    <dc:date>2016-11-29T22:40:03Z</dc:date>
    <item>
      <title>Is it possible to do a delta grouped by a field in a search to find a missing sequence?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-do-a-delta-grouped-by-a-field-in-a-search-to/m-p/251150#M75024</link>
      <description>&lt;P&gt;Is it possible to do delta groupby some field? I have an application which is processing data from multiple queues. Each queue has independent ever increment sequence number. I need to find a missing sequence with search. The log format looks like:&lt;/P&gt;

&lt;P&gt;2016-11-21 17:15:40,803 queueName=q1, seqid = 12&lt;BR /&gt;
2016-11-21 17:26:40,803 queueName=q2, seqid = 32&lt;BR /&gt;
2016-11-21 17:27:40,803 queueName=q3, seqid = 114&lt;BR /&gt;
2016-11-21 17:44:41,803 queueName=q3, seqid = 113&lt;BR /&gt;
2016-11-21 17:50:49,803 queueName=q2, seqid = 34&lt;BR /&gt;
2016-11-21 17:51:40,803 queueName=q2, seqid = 33&lt;BR /&gt;
2016-11-21 17:53:40,803 queueName=q1, seqid = 13&lt;BR /&gt;
2016-11-21 17:58:22,803 queueName=q3, seqid = 116&lt;/P&gt;

&lt;P&gt;I am using &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sort queueName,seqid | delta seqid as seq_diff | search seq_diff &amp;gt; 1 | table queueName,seqid,seqid_diff
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this does not take care of checking diff across queueName. How do I restrict delta by  queueName?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 22:28:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-do-a-delta-grouped-by-a-field-in-a-search-to/m-p/251150#M75024</guid>
      <dc:creator>avanishm</dc:creator>
      <dc:date>2016-11-29T22:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to do a delta grouped by a field in a search to find a missing sequence?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-do-a-delta-grouped-by-a-field-in-a-search-to/m-p/251151#M75025</link>
      <description>&lt;P&gt;How about you use &lt;CODE&gt;autoregress&lt;/CODE&gt; which will be able to look at previous event something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base query to return all the events
| sort queueName, seqId
| autoregress queueName as oldQ p=1
| autoregress seqId as oldSeq p=1
| eval flag=if( ( queueName=oldQ ) AND ( seqId != (oldSeq +1)), 1, 0)
| table queueName, seqId, oldSeqId, flag
| where flag=1
| fields -flag
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can alternatively tweak the if condition of &lt;CODE&gt;( seqId != (oldSeq +1))&lt;/CODE&gt; to something like &lt;CODE&gt;( seqId - oldSeq &amp;gt; 1)&lt;/CODE&gt; or whichever way you feel shall better represent your case.&lt;/P&gt;

&lt;P&gt;Also if you feel sorting on &lt;CODE&gt;_time&lt;/CODE&gt; will also help put the sequences in a better order than already done by &lt;CODE&gt;| sort queueName, seqId&lt;/CODE&gt; the try to combine &lt;CODE&gt;_time&lt;/CODE&gt; in there to make it &lt;CODE&gt;| sort queueName, seqId, _time&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 22:40:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-do-a-delta-grouped-by-a-field-in-a-search-to/m-p/251151#M75025</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-11-29T22:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to do a delta grouped by a field in a search to find a missing sequence?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-do-a-delta-grouped-by-a-field-in-a-search-to/m-p/251152#M75026</link>
      <description>&lt;P&gt;Try &lt;CODE&gt;streamstats&lt;/CODE&gt; instead &lt;A href="http://blogs.splunk.com/2014/04/01/search-command-stats-eventstats-and-streamstats-2/"&gt;http://blogs.splunk.com/2014/04/01/search-command-stats-eventstats-and-streamstats-2/&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | streamstats window=1 current=f values(seqid) as next_seqid by queueName | eval seq_diff = next_seqid - seqid | where seq_diff &amp;gt; 1 | table queueName seqid seqid_diff
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Nov 2016 23:13:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Is-it-possible-to-do-a-delta-grouped-by-a-field-in-a-search-to/m-p/251152#M75026</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-11-29T23:13:02Z</dc:date>
    </item>
  </channel>
</rss>

