<?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: Average/Mean time differences by device in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401419#M71475</link>
    <description>&lt;P&gt;Thanks, the version with streamstats works! &lt;BR /&gt;
Thanks a lot!&lt;/P&gt;</description>
    <pubDate>Thu, 21 Feb 2019 07:59:02 GMT</pubDate>
    <dc:creator>michaelhitzelbe</dc:creator>
    <dc:date>2019-02-21T07:59:02Z</dc:date>
    <item>
      <title>Average/Mean time differences by device</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401414#M71470</link>
      <description>&lt;P&gt;I have data from several devices in the same index and sourcetype. I'd like to get the average/mean diffs for each specific device.&lt;/P&gt;

&lt;P&gt;The data looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time   device
2019-02-19 11:02:36 245
2019-02-19 11:02:36 245
2019-02-19 11:02:34 373
2019-02-19 11:02:34 234
2019-02-19 11:02:33 204
2019-02-19 11:02:33 204
2019-02-19 11:02:33 303
2019-02-19 11:02:33 303
2019-02-19 11:02:33 200
2019-02-19 11:02:33 381
2019-02-19 11:02:33 381
2019-02-19 11:02:32 271
2019-02-19 11:02:32 271
2019-02-19 11:02:30 080
2019-02-19 11:02:30 080
2019-02-19 11:02:30 181
2019-02-19 11:02:30 181
2019-02-19 11:02:28 081
2019-02-19 11:02:28 081
2019-02-19 11:02:28 301
2019-02-19 11:02:28 301
2019-02-19 11:02:28 156
2019-02-19 11:02:28 156
2019-02-19 11:02:27 316
2019-02-19 11:02:27 316
2019-02-19 11:02:27 363
2019-02-19 11:02:27 363
2019-02-19 11:02:27 262
2019-02-19 11:02:27 262
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'd like to get a table like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    device | average diff |mean diff
    245      |           23 |      25 
    381      |           17 |      21 
    245      |           31 |      19 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Feb 2019 10:12:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401414#M71470</guid>
      <dc:creator>michaelhitzelbe</dc:creator>
      <dc:date>2019-02-19T10:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Average/Mean time differences by device</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401415#M71471</link>
      <description>&lt;P&gt;Can you explain in what reference you are calculating the diff?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 13:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401415#M71471</guid>
      <dc:creator>ashajambagi</dc:creator>
      <dc:date>2019-02-19T13:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Average/Mean time differences by device</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401416#M71472</link>
      <description>&lt;P&gt;It was just random numbers...&lt;/P&gt;

&lt;P&gt;I can get the diff without respecting the devices by using this search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=device_events | sort - _time | delta _time AS timeDeltaS | eval timeDeltaS=toString(abs(timeDeltaS),"duration") | table _time device timeDeltaS
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which gives me something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time               device  timeDeltaS
2019-02-19 10:46:09 111  
2019-02-19 10:46:09 111 00:00:00
2019-02-19 10:46:08 112 00:00:01
2019-02-19 10:45:47 112 00:00:21
2019-02-19 10:44:47 112 00:01:00
2019-02-19 10:43:56 135 00:00:51
2019-02-19 10:43:47 112 00:00:09
2019-02-19 10:42:47 112 00:01:00
2019-02-19 10:41:47 112 00:01:00
2019-02-19 10:40:47 112 00:01:00
2019-02-19 10:40:40 135 00:00:07
2019-02-19 10:40:40 135 00:00:00
2019-02-19 10:40:39 135 00:00:01
2019-02-19 10:40:38 135 00:00:01
2019-02-19 10:40:38 135 00:00:00
2019-02-19 10:40:38 135 00:00:00
2019-02-19 10:40:38 135 00:00:00
2019-02-19 10:40:38 135 00:00:00
2019-02-19 10:40:38 135 00:00:00
2019-02-19 10:40:38 135 00:00:00
2019-02-19 10:40:37 135 00:00:01
2019-02-19 10:40:37 135 00:00:00
2019-02-19 10:40:37 135 00:00:00
2019-02-19 10:40:37 135 00:00:00
2019-02-19 10:40:06 135 00:00:31
2019-02-19 10:40:06 135 00:00:00
2019-02-19 10:40:06 135 00:00:00
2019-02-19 10:40:05 135 00:00:01
2019-02-19 10:40:05 135 00:00:00
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Feb 2019 13:20:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401416#M71472</guid>
      <dc:creator>michaelhitzelbe</dc:creator>
      <dc:date>2019-02-19T13:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Average/Mean time differences by device</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401417#M71473</link>
      <description>&lt;P&gt;You might need to be more specific as to how you calculate the average/mean difference for each device.&lt;/P&gt;

&lt;P&gt;Based on your comment, perhaps this search can help you:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=device_events | sort -_time | delta _time AS timeDeltaS | eval timeDeltaS=abs(timeDeltaS) | stats mean(timeDeltaS) as average_diff by device
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT: Okay, so based on your comment below, you might want to use streamstats instead, since delta does not support the by clause. Check this out:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=device_events
| streamstats window=1 current=false global=false first(_time) as previous_time by device
| eval diff_s=previous_time-_time
| stats ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Feb 2019 07:22:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401417#M71473</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2019-02-20T07:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Average/Mean time differences by device</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401418#M71474</link>
      <description>&lt;P&gt;Thanks. I tried that, too, but it does the "splitting" by device one step too late.&lt;BR /&gt;
I would like to calculate the diff by device, so I would like something like  &lt;CODE&gt;... delta _time by device&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So if I have these events:&lt;BR /&gt;
2019-02-20 8:00:00 deviceA&lt;BR /&gt;
2019-02-20 8:00:10 deviceB&lt;BR /&gt;
2019-02-20 8:00:20 deviceA&lt;BR /&gt;
2019-02-20 8:00:30 deviceB&lt;/P&gt;

&lt;P&gt;The search would result in mean/average time diffs of 10s for both, deviceA and deviceB.&lt;BR /&gt;
What I really would like to have would be 20s, as the events of the respective devices are 20s apart.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 09:18:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401418#M71474</guid>
      <dc:creator>michaelhitzelbe</dc:creator>
      <dc:date>2019-02-20T09:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Average/Mean time differences by device</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401419#M71475</link>
      <description>&lt;P&gt;Thanks, the version with streamstats works! &lt;BR /&gt;
Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 07:59:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Average-Mean-time-differences-by-device/m-p/401419#M71475</guid>
      <dc:creator>michaelhitzelbe</dc:creator>
      <dc:date>2019-02-21T07:59:02Z</dc:date>
    </item>
  </channel>
</rss>

