<?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: How do I find the delta with the previous count value for each host? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174417#M50050</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;you can use streamstats to solve this. Try to use something like this after the search that leads to the results you showed in your post:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| streamstats current=f last(Host1) as Host1_old last(Host2) as Host2_old | eval delta1=Host1 - Host1_old | eval delta2=Host2 - Host2_old&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;What happens here is:&lt;BR /&gt;
 1. The part &lt;CODE&gt;| streamstats current=f last(Host1) as Host1_old&lt;/CODE&gt; gives you the previos event of the Host value&lt;BR /&gt;
 2. The part  &lt;CODE&gt;| eval delta1=Host1 - Host1_old &lt;/CODE&gt; calculates the delta from the current Host value and the previous Host value&lt;/P&gt;

&lt;P&gt;Greetings&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 06:58:37 GMT</pubDate>
    <dc:creator>tom_frotscher</dc:creator>
    <dc:date>2020-09-29T06:58:37Z</dc:date>
    <item>
      <title>How do I find the delta with the previous count value for each host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174416#M50049</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have data which always gives me a cumulative count for each server with time as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search&amp;gt;| timechart span=4m values(value) as TotalCount by Host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Creates results as below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                 Host1        Host2
2015-08-13 09:04:00 3448034.0   3310489.0
2015-08-13 09:08:00 3448073.0   3310525.0
2015-08-13 09:12:00 3448106.0   3310561.0
2015-08-13 09:16:00 3448139.0   3310594.0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to find delta with previous value for each host and want in similar table format.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2015 09:11:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174416#M50049</guid>
      <dc:creator>praspai</dc:creator>
      <dc:date>2015-08-14T09:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find the delta with the previous count value for each host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174417#M50050</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;you can use streamstats to solve this. Try to use something like this after the search that leads to the results you showed in your post:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| streamstats current=f last(Host1) as Host1_old last(Host2) as Host2_old | eval delta1=Host1 - Host1_old | eval delta2=Host2 - Host2_old&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;What happens here is:&lt;BR /&gt;
 1. The part &lt;CODE&gt;| streamstats current=f last(Host1) as Host1_old&lt;/CODE&gt; gives you the previos event of the Host value&lt;BR /&gt;
 2. The part  &lt;CODE&gt;| eval delta1=Host1 - Host1_old &lt;/CODE&gt; calculates the delta from the current Host value and the previous Host value&lt;/P&gt;

&lt;P&gt;Greetings&lt;/P&gt;

&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:58:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174417#M50050</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2020-09-29T06:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find the delta with the previous count value for each host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174418#M50051</link>
      <description>&lt;P&gt;A solution could be a scheduled search every 5 minutes&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;.... earliest=-5m@m latest=@m | max(value) as value | convert timeformat="%Y-%m-%d %H:%M" ctime(_time) AS this_time  | inputlookup history value this_time OUTPUNEW value as old_value, this_time | eval delta=value-old_value | outputlookup append=true history
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;would give you a lookup table with the deltas, but I guess there is room for improvement in this solution &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2015 13:38:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174418#M50051</guid>
      <dc:creator>FritzWittwer_ol</dc:creator>
      <dc:date>2015-08-14T13:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find the delta with the previous count value for each host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174419#M50052</link>
      <description>&lt;P&gt;I can have any number of host in output so while executing query it should be generate difference between previous reading automatically&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2015 13:48:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174419#M50052</guid>
      <dc:creator>praspai</dc:creator>
      <dc:date>2015-08-14T13:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I find the delta with the previous count value for each host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174420#M50053</link>
      <description>&lt;P&gt;If all your hosts have a common prefix you can use something like &lt;CODE&gt;| stats last(Host*) as Host*&lt;/CODE&gt;. Then you can use a foreach to calculate the delta of all Host fields.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 06:58:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-find-the-delta-with-the-previous-count-value-for-each/m-p/174420#M50053</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2020-09-29T06:58:40Z</dc:date>
    </item>
  </channel>
</rss>

