<?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: Cumulative counters with &amp;quot;slice&amp;quot; logic in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140760#M38929</link>
    <description>&lt;P&gt;Append this after the &lt;CODE&gt;timechart&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | accum Error | accum Success
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How does that not calculate your cumulative values?&lt;/P&gt;</description>
    <pubDate>Thu, 24 Apr 2014 11:13:16 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-04-24T11:13:16Z</dc:date>
    <item>
      <title>Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140757#M38926</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;

&lt;P&gt;I am working on task: Create cumulative chart for counting Success and Error entities, by 1 hour &lt;STRONG&gt;slice&lt;/STRONG&gt; interval, with checking &lt;STRONG&gt;latest [Status]&lt;/STRONG&gt; value by [ID] and [StatusDateTime] to &lt;STRONG&gt;every [Slice]&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;"Slice logic"&lt;/EM&gt; - for example, exist next Events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ID   Status   StatusDateTime
------------------------------
1    Error    2014-04-23 10:55
2    Success  2014-04-23 10:55
1    Success  2014-04-23 11:55
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Need to get next result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Slice              Success    Error
------------------------------------
2014-04-23 11:00   1          1
2014-04-23 12:00   2          0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I know how to calculate count separately for 1 hour periods:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="log_index"  
| eval GroupDate=strftime(relative_time(StatusDateTime, "+1h@h"), "%Y-%m-%d %H:%M")  
| stats latest(Status) as Status by ID, GroupDate  
| stats c(eval(Status="Success")) as SuccessCount, c(eval(Status="Error")) as ErrorCount by GroupDate
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In SQL, I can do subqueries for each period and calculate it (specifying &lt;STRONG&gt;latest&lt;/STRONG&gt; in Sub-Search as &lt;STRONG&gt;GroupDate&lt;/STRONG&gt;). But, as I understood, Splunk does not support passing parameters/values from Main-Search to Sub-Search, is it true?&lt;/P&gt;

&lt;P&gt;I do not have any ideas how to create needed cumulative logic.&lt;BR /&gt;
Anyone can guide me please on this?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2014 18:46:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140757#M38926</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-04-23T18:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140758#M38927</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="log_index" | bucket span=1h _time as slice | dedup ID slice | timechart span=1h count by Status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;bucket&lt;/CODE&gt; will take care of your one-hour-slices, and the &lt;CODE&gt;dedup&lt;/CODE&gt; will discard all but the latest event per slice for every ID.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Apr 2014 22:53:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140758#M38927</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-23T22:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140759#M38928</link>
      <description>&lt;P&gt;Martin, great thanks!&lt;/P&gt;

&lt;P&gt;But, it is not cumulative. With this search, I'll get in slice 2014-04-23 12:00 - 1 Success and 0 Error.&lt;/P&gt;

&lt;P&gt;I know about "accum" and "delta" operators, but they doesn't allow realize cumulative "slice logic by ID" fully.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 11:10:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140759#M38928</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-04-24T11:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140760#M38929</link>
      <description>&lt;P&gt;Append this after the &lt;CODE&gt;timechart&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | accum Error | accum Success
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How does that not calculate your cumulative values?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 11:13:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140760#M38929</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-24T11:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140761#M38930</link>
      <description>&lt;P&gt;Martin, it's not fully what I need. I described task in the my first post. As you can see, in the second slice total Success increased, but total Error decreased.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 12:53:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140761#M38930</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-04-24T12:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140762#M38931</link>
      <description>&lt;P&gt;In my mind a cumulative value cannot decrease, so maybe we're thinking of different things.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 12:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140762#M38931</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-24T12:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140763#M38932</link>
      <description>&lt;P&gt;Therefore I called it as "slice cumulative logic" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
I understand that it's unordinary logic, but there is such requirements.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 13:08:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140763#M38932</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-04-24T13:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140764#M38933</link>
      <description>&lt;P&gt;Googling that term yields this question as the top result for me: &lt;A href="https://www.google.com/search?q=slice+cumulative+logic"&gt;https://www.google.com/search?q=slice+cumulative+logic&lt;/A&gt;&lt;BR /&gt;
I guess you'll have to explain what you mean by that...&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 13:10:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140764#M38933</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-24T13:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140765#M38934</link>
      <description>&lt;P&gt;Hm... Sorry, I'm not sure that it's realy called as "slice cumulative logic", it's only my version. Therefore I tried to describe it in the first post.&lt;/P&gt;

&lt;P&gt;Explanation: At every slice, search must include all events in previous slices. For example: if earliest boundary it's 8:00 AM, then:&lt;BR /&gt;
1) At 9:00 AM - Includes events from 8:00 to 9:00 AM;&lt;BR /&gt;
2) At 10:00 AM - Includes events from 8:00 to 10:00 AM;&lt;BR /&gt;
3) At 11:00 AM - Includes events from 8:00 to 11:00 AM;&lt;BR /&gt;
and so on.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 13:25:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140765#M38934</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-04-24T13:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140766#M38935</link>
      <description>&lt;P&gt;Isn't that what &lt;CODE&gt;accum&lt;/CODE&gt; does?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 13:38:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140766#M38935</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-24T13:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140767#M38936</link>
      <description>&lt;P&gt;Unfortunately no... I need to calculate all slices in one search, "accum" will not give me result as in example.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 13:51:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140767#M38936</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-04-24T13:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140768#M38937</link>
      <description>&lt;P&gt;I guess I don't understand what difference from &lt;CODE&gt;accum&lt;/CODE&gt; you'd like...&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 13:52:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140768#M38937</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-04-24T13:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140769#M38938</link>
      <description>&lt;P&gt;More detailed example.&lt;BR /&gt;
Events in index:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ID  Status      StatusDateTime
--------------------------------------
1   Error       0:30
2   Success     0:30
1   Success     1:30
3   Error       1:30
4   Error       2:30
3   Success     3:30
4   Success     4:30
5   Error       4:30
6   Success     5:30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Required overall result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Slice   Success   Error
------------------------------------
1:00    1         1
2:00    2         1
3:00    2         2
4:00    3         1
5:00    4         1
6:00    5         1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Main issue - correctly calculate total Error's count.&lt;BR /&gt;
If added new event, with the same ID and status "Success" (that before then had "Error"), total Error's count must decrease.&lt;BR /&gt;
"Success" it's a final Status for each ID.&lt;BR /&gt;
If already exists event with Status=Success and ID=1, then  new event with Status=Error and ID=1 will not be added.&lt;BR /&gt;
I have to get this result in one search, is it realizable?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 14:13:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140769#M38938</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-04-24T14:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140770#M38939</link>
      <description>&lt;P&gt;What should be the output if you have another entry like this&lt;/P&gt;

&lt;H2&gt;ID   Status   StatusDateTime&lt;/H2&gt;

&lt;P&gt;1    Error    2014-04-23 12:55&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 14:19:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140770#M38939</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-24T14:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140771#M38940</link>
      <description>&lt;P&gt;Somesin2, thanks for this question, I forgot to say about this case: "Success" it's a final Status for each ID.&lt;BR /&gt;
If already exists event with Status=Success and ID=1, then  new event with Status=Error and ID=1 will not be added.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Apr 2014 14:51:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140771#M38940</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-04-24T14:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140772#M38941</link>
      <description>&lt;P&gt;I guess the output should be like this for your example&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Slice   Success   Error
------------------------------------
1:00    1         1
2:00    2         1
3:00    2         2
4:00    3         1
5:00    4         1
6:00    5         1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try this if it works&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=log_index | bucket span=1h _time as slice | eval slice=slice+3600| dedup ID slice | sort _time,ID| streamstats current=f window=2 first(Status) as fStatus by ID | eval ErrorCount=case(Status="Success" AND isnotnull(fStatus),-1, Status="Error",1) | stats count(eval(Status="Success")) as SuccessCount, sum(ErrorCount) as ErrorCount by slice | convert ctime(slice) as slice| streamstats sum(ErrorCount) as ErrorCount sum(SuccessCount) as SuccessCount | fillnull value=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Apr 2014 18:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140772#M38941</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-04-24T18:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140773#M38942</link>
      <description>&lt;P&gt;This example works only for cases when the "error" has been corrected in adjacent periods. With a larger gap in time, it will not work. However, the example is useful for another task, thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2014 06:01:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140773#M38942</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-05-06T06:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Cumulative counters with "slice" logic</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140774#M38943</link>
      <description>&lt;P&gt;In the end, we decided to create an internal cumulative index and accumulate therein summary statistics using &lt;STRONG&gt;scheduled search&lt;/STRONG&gt; (&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Usesummaryindexing"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Usesummaryindexing&lt;/A&gt;).&lt;/P&gt;

&lt;P&gt;Thank you all for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 06 May 2014 06:05:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Cumulative-counters-with-quot-slice-quot-logic/m-p/140774#M38943</guid>
      <dc:creator>Nikita_Danilov</dc:creator>
      <dc:date>2014-05-06T06:05:11Z</dc:date>
    </item>
  </channel>
</rss>

