<?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 duration in each state for specific time range in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/duration-in-each-state-for-specific-time-range/m-p/95689#M182473</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
What would be the best approach for building a query that for a given time-range gives for each device the amount of time in each state?&lt;/P&gt;

&lt;P&gt;I have a system that tosses in logs with "Timestamp, DeviceName, NewState" upon each state change.&lt;BR /&gt;
e.g.&lt;BR /&gt;
Time=03/17/2012 16:00:23;DeviceName=ABC;Down&lt;BR /&gt;
Time=03/18/2012 14:16:23;DeviceName=ABC;Up&lt;BR /&gt;
Time=03/18/2012 14:19:23;DeviceName=ABC;Down&lt;BR /&gt;
Time=03/18/2012 14:21:23;DeviceName=ABC;On-Backup&lt;BR /&gt;
Time=03/18/2012 18:49:23;DeviceName=ABC;Up&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;For example, from 3/18/2012 12:00:00 - 3/18/2012 15:00:00 could you give me a query that would yield:&lt;BR /&gt;
Device;State;&lt;BR /&gt;
ABC;UP; 3 minutes = 00:03:00&lt;BR /&gt;
ABC;Down;2min (from outage in middle) + 02:16:23 (from 12:00:00 til it went up at 14:16:23) = 02:18:23&lt;BR /&gt;
ABC;On-Backup;00:38:37 (from 14:21:23 - 15:00:00)&lt;/P&gt;</description>
    <pubDate>Sun, 18 Mar 2012 20:29:34 GMT</pubDate>
    <dc:creator>rferrante</dc:creator>
    <dc:date>2012-03-18T20:29:34Z</dc:date>
    <item>
      <title>duration in each state for specific time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/duration-in-each-state-for-specific-time-range/m-p/95689#M182473</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
What would be the best approach for building a query that for a given time-range gives for each device the amount of time in each state?&lt;/P&gt;

&lt;P&gt;I have a system that tosses in logs with "Timestamp, DeviceName, NewState" upon each state change.&lt;BR /&gt;
e.g.&lt;BR /&gt;
Time=03/17/2012 16:00:23;DeviceName=ABC;Down&lt;BR /&gt;
Time=03/18/2012 14:16:23;DeviceName=ABC;Up&lt;BR /&gt;
Time=03/18/2012 14:19:23;DeviceName=ABC;Down&lt;BR /&gt;
Time=03/18/2012 14:21:23;DeviceName=ABC;On-Backup&lt;BR /&gt;
Time=03/18/2012 18:49:23;DeviceName=ABC;Up&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;For example, from 3/18/2012 12:00:00 - 3/18/2012 15:00:00 could you give me a query that would yield:&lt;BR /&gt;
Device;State;&lt;BR /&gt;
ABC;UP; 3 minutes = 00:03:00&lt;BR /&gt;
ABC;Down;2min (from outage in middle) + 02:16:23 (from 12:00:00 til it went up at 14:16:23) = 02:18:23&lt;BR /&gt;
ABC;On-Backup;00:38:37 (from 14:21:23 - 15:00:00)&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2012 20:29:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/duration-in-each-state-for-specific-time-range/m-p/95689#M182473</guid>
      <dc:creator>rferrante</dc:creator>
      <dc:date>2012-03-18T20:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: duration in each state for specific time range</title>
      <link>https://community.splunk.com/t5/Splunk-Search/duration-in-each-state-for-specific-time-range/m-p/95690#M182474</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Not exactly what you asked for, but you could try something like this:&lt;BR /&gt;
   DeviceName=* |transaction DeviceName startswith=Down endswith=Up |table _time duration&lt;BR /&gt;
That will give how long it was down for. &lt;/P&gt;

&lt;P&gt;Or to see how long it's been on battery try this:&lt;BR /&gt;
   DeviceName=* | transaction DeviceName startswith=On-Backup max-events=2 | table _time duration&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2012 22:43:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/duration-in-each-state-for-specific-time-range/m-p/95690#M182474</guid>
      <dc:creator>GKC_DavidAnso</dc:creator>
      <dc:date>2012-03-18T22:43:11Z</dc:date>
    </item>
  </channel>
</rss>

