<?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: grouping and delta in search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96367#M24900</link>
    <description>&lt;P&gt;Your data is already binnned into daily chunks (from the look of it) so you probably dont need the &lt;CODE&gt;| bin _time span=5m&lt;/CODE&gt; part&lt;/P&gt;

&lt;P&gt;xyseries is like chart/timechart apart from you dont need to use an aggregate function. &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Xyseries"&gt;docs&lt;/A&gt;  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;makecontinuous _time&lt;/CODE&gt; looks at the _time field, and makes it continuous if there's any missing samples. This is needed for splunk to print the times on the graphs in a readable format. (timechart does this bit automatically)&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jan 2013 15:17:20 GMT</pubDate>
    <dc:creator>jonuwz</dc:creator>
    <dc:date>2013-01-23T15:17:20Z</dc:date>
    <item>
      <title>grouping and delta in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96364#M24897</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I have the following problem with a search.&lt;/P&gt;

&lt;P&gt;This is my data &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01/23/2013 08:00 user=Mimi pieces=23 price=30 region=noe
01/23/2013 09:00 user=Mimi pieces=0 price=33 region=ooe
01/23/2013 10:00 user=Mimi pieces=13 price=30 region=w
01/23/2013 08:00 user=Franz pieces=26 price=23 region=noe
01/23/2013 09:00 user=Franz pieces=21 price=73 region=ooe
01/23/2013 10:00 user=Franz pieces=43 price=12 region=w
01/23/2013 08:00 user=Sandra pieces=565 price=54 region=noe
01/23/2013 09:00 user=Sandra pieces=453 price=12 region=ooe
01/23/2013 10:00 user=Sandra pieces=233 price=21 region=w
01/23/2013 08:00 user=Susi pieces=0 price=320 region=noe
01/23/2013 09:00 user=Susi pieces=5 price=3 region=ooe
01/23/2013 10:00 user=Susi pieces=50 price=33 region=w
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to see the delta for each user and each time, how many pieces the user have sold.&lt;BR /&gt;
If I try it with a single user, this works fine&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=delta  user=sandra | reverse | delta pieces as delta | stats avg(pieces) as pieces,avg(delta) as delta by user,_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I would like to see all users with there deltas and I am ommit the user=sandra then I get a list with all users and the delta is calculated between the old and the new user.&lt;/P&gt;

&lt;P&gt;How I can make the search, that I only get the delta values for each user separated in a list to make a chart?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Update:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;This search looks better, but how I can add the delta for pieces&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=delta  user=* | reverse | chart avg(pieces) as pieces by _time, user

_time   Franz   Mimi    Sandra  Susi
1   1/23/13 8:00:00.000 AM  26.000000   23.000000   565.000000  0.000000
2   1/23/13 9:00:00.000 AM  21.000000   0.000000    453.000000  5.000000
3   1/23/13 10:00:00.000 AM 43.000000   13.000000   233.000000  50.000000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Update:&lt;/P&gt;

&lt;P&gt;I think I'm near to the answer&lt;BR /&gt;
I can use the parameter for delta p=4 then, splunk calculate the right values of each user&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=delta | reverse | stats avg(pieces) as pieces by _time, user | delta pieces p=4

_time   user    pieces  delta(pieces)
1   1/23/13 8:00:00.000 AM  Franz   26.000000   
2   1/23/13 8:00:00.000 AM  Mimi    23.000000   
3   1/23/13 8:00:00.000 AM  Sandra  565.000000  
4   1/23/13 8:00:00.000 AM  Susi    0.000000    
5   1/23/13 9:00:00.000 AM  Franz   21.000000   -5.000000
6   1/23/13 9:00:00.000 AM  Mimi    0.000000    -23.000000
7   1/23/13 9:00:00.000 AM  Sandra  453.000000  -112.000000
8   1/23/13 9:00:00.000 AM  Susi    5.000000    5.000000
9   1/23/13 10:00:00.000 AM Franz   43.000000   22.000000
10  1/23/13 10:00:00.000 AM Mimi    13.000000   13.000000
11  1/23/13 10:00:00.000 AM Sandra  233.000000  -220.000000
12  1/23/13 10:00:00.000 AM Susi    50.000000   45.000000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have tried to combine a search with a subsearch  to get the distinct users but I get a error message for the delta function &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=delta | reverse | stats avg(pieces) as pieces by _time, user | delta pieces [search sourcetype=delta  | stats dc(user) as tmp | eval tmp= "p=" . tmp]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks#Rob&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2013 11:25:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96364#M24897</guid>
      <dc:creator>RobertRi</dc:creator>
      <dc:date>2013-01-23T11:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: grouping and delta in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96365#M24898</link>
      <description>&lt;P&gt;You need to use streamstats to calculate deltas if you need a 'by' clause:&lt;/P&gt;

&lt;P&gt;Example :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* earliest=-1h@h
| bin _time span=5m
| stats count by _time, sourcetype
| streamstats window=2 global=f current=f first(count) as p_count by sourcetype
| eval delta=count-p_count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives you the the change in count every 5 minutes per sourcetype.&lt;/P&gt;

&lt;P&gt;Add this if you want to visualise it :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | xyseries _time,sourcetype,delta
 | makecontinuous _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jan 2013 14:32:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96365#M24898</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-01-23T14:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: grouping and delta in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96366#M24899</link>
      <description>&lt;P&gt;Hi jonuwz.&lt;/P&gt;

&lt;P&gt;This command looks very difficult to me :-), but the first part works for my data.&lt;BR /&gt;
I had to modify window= attribute from streamstats to 1, that I get the last previous sample correct. Now this command works fine&lt;/P&gt;

&lt;P&gt;sourcetype=delta | reverse | bin _time span=5 | stats avg(pieces) as pieces by _time, user | streamstats window=1 global=f current=f first(pieces) as p_pieces by user | eval delta=pieces-p_pieces&lt;/P&gt;

&lt;P&gt;The second part is totally encrypted for me, could you explain in short words how the second part works&lt;/P&gt;

&lt;P&gt;Thanks for your help&lt;BR /&gt;
Rob&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:10:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96366#M24899</guid>
      <dc:creator>RobertRi</dc:creator>
      <dc:date>2020-09-28T13:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: grouping and delta in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96367#M24900</link>
      <description>&lt;P&gt;Your data is already binnned into daily chunks (from the look of it) so you probably dont need the &lt;CODE&gt;| bin _time span=5m&lt;/CODE&gt; part&lt;/P&gt;

&lt;P&gt;xyseries is like chart/timechart apart from you dont need to use an aggregate function. &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Xyseries"&gt;docs&lt;/A&gt;  &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;makecontinuous _time&lt;/CODE&gt; looks at the _time field, and makes it continuous if there's any missing samples. This is needed for splunk to print the times on the graphs in a readable format. (timechart does this bit automatically)&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2013 15:17:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96367#M24900</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-01-23T15:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: grouping and delta in search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96368#M24901</link>
      <description>&lt;P&gt;Thanks a lot buddy. This solved my problem. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Feb 2015 12:01:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/grouping-and-delta-in-search/m-p/96368#M24901</guid>
      <dc:creator>neerajsafenet</dc:creator>
      <dc:date>2015-02-17T12:01:00Z</dc:date>
    </item>
  </channel>
</rss>

