<?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 you calculate the average duration of timestamps? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414805#M119466</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;..base search...
| streamstats current=false window=1  last(_time) as time_of_last_change by namespace
 | eval diffoflastchange=_time-time_of_last_change
| timechart span=1d avg(diffoflastchange)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Nov 2018 18:50:59 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2018-11-29T18:50:59Z</dc:date>
    <item>
      <title>How do you calculate the average duration of timestamps?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414803#M119464</link>
      <description>&lt;P&gt;I want to calculate the average time between updates for my data — I.E: on average, how often is this data changing? &lt;BR /&gt;
I'm able to get the changes in data and the delta between those changes by using the streamstats command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| table _time namespace diffoflastchange
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I end up with the columns above where the important column is diffoflastchange, which is really...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats current=false  last(count) as prev_count last(_time) as time_of_last_change by namespace
| eval diffoflastchange=now()-time_of_last_change
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;...so now, I got all my timestamps per above, but I can't figure how to average them together to get the, let's say, daily average over a 2 week period.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 18:19:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414803#M119464</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-11-29T18:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do you calculate the average duration of timestamps?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414804#M119465</link>
      <description>&lt;P&gt;looking at this again I think even my eval diffoflastchange is wrong b/c I want that diff to be from the previous time_of_last_change ... hmmm&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:13:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414804#M119465</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2020-09-29T22:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do you calculate the average duration of timestamps?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414805#M119466</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;..base search...
| streamstats current=false window=1  last(_time) as time_of_last_change by namespace
 | eval diffoflastchange=_time-time_of_last_change
| timechart span=1d avg(diffoflastchange)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Nov 2018 18:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414805#M119466</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-11-29T18:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do you calculate the average duration of timestamps?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414806#M119467</link>
      <description>&lt;P&gt;no I don't think this produces accurate results - I'd like to see avg in HH:MM:SS by day&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 20:38:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414806#M119467</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-11-29T20:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do you calculate the average duration of timestamps?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414807#M119468</link>
      <description>&lt;P&gt;It currently gives the result in seconds. You can format in duration format using &lt;CODE&gt;tostring&lt;/CODE&gt;function of eval. See this for example&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/367836/how-to-convert-the-output-of-tostring-or-convert-a.html"&gt;https://answers.splunk.com/answers/367836/how-to-convert-the-output-of-tostring-or-convert-a.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 20:51:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414807#M119468</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-11-29T20:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do you calculate the average duration of timestamps?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414808#M119469</link>
      <description>&lt;P&gt;or use eval diffoflastchange =strftime(diffoflastchange,"%HH:%MM:%SS")&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 19:27:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414808#M119469</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-11-30T19:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do you calculate the average duration of timestamps?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414809#M119470</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Search Here
| streamstats current=false window=2 range(_time) AS diffoflastchange
| timechart span=1d avg(diffoflastchange)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Nov 2018 22:45:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414809#M119470</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-11-30T22:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do you calculate the average duration of timestamps?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414810#M119471</link>
      <description>&lt;P&gt;Let me give a more concrete example of my data since none of these suggestions seem to be working.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time       
Processed_time      
namespace       
time_of_last_change     
prev_count      
actualchange    
1   2018-11-28 11:15:01     1543421701  sample  1543422601  130701  20
2   2018-11-28 08:15:01     1543410901  sample  1543411801  130681  4 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got my query to the point to where I get back data like the above - now what I really want is to take these two values which between them is 3hrs and if these were the only two values by namespace for the month, week whatever then my average update time would be ~3hrs - but I can't seem to get that to compute&lt;/P&gt;</description>
      <pubDate>Sat, 01 Dec 2018 20:57:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-calculate-the-average-duration-of-timestamps/m-p/414810#M119471</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-12-01T20:57:18Z</dc:date>
    </item>
  </channel>
</rss>

