<?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 to calculate time difference in statistics using another field in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395470#M6713</link>
    <description>&lt;P&gt;True, but one should NEVER use &lt;CODE&gt;transaction&lt;/CODE&gt; if there is ANY other way.  In this case there is.  The overhead and unscalability of &lt;CODE&gt;transaction&lt;/CODE&gt; means that it should be avoided at all costs.&lt;/P&gt;</description>
    <pubDate>Thu, 10 May 2018 14:32:22 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2018-05-10T14:32:22Z</dc:date>
    <item>
      <title>How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395464#M6707</link>
      <description>&lt;P&gt;Hi,this is the statistics i have&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;dv_cmdb_ci  number  _time   state
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1   A                              B 2018-04-03 15:00:51    Assigned&lt;BR /&gt;
2   A                              B 2018-04-03 15:03:28    Work in Progress&lt;BR /&gt;
3   A                              B 2018-04-03 18:09:46    Work in Progress&lt;BR /&gt;
4   A                              B 2018-04-03 18:11:36    Assigned&lt;BR /&gt;
5   A                              B 2018-04-03 18:14:53    Assigned&lt;BR /&gt;
6   A                              B 2018-04-03 18:22:14    Work in Progress&lt;BR /&gt;
7   A                              B 2018-04-03 18:51:07    Work in Progress&lt;BR /&gt;
8   A                              B 2018-04-03 18:57:26    Work in Progress&lt;BR /&gt;
9   A                              B 2018-04-03 19:18:41    Work in Progress&lt;BR /&gt;
10  A                              B 2018-04-04 17:25:59    Work in Progress&lt;BR /&gt;
11  A                              B 2018-04-04 17:26:25    Pending&lt;BR /&gt;
12  A                              B 2018-04-19 16:18:43    Resolved&lt;BR /&gt;
13  A                              B 2018-04-22 17:00:07    Closed&lt;/P&gt;

&lt;P&gt;This is for single host and single ticket data.&lt;/P&gt;

&lt;P&gt;How can i get the time difference when ticket was in pending to Resolve.&lt;/P&gt;

&lt;P&gt;From above based on state my time difference should be (2018-04-19 16:18:43)-(2018-04-04 17:26:25)=difference in second.&lt;/P&gt;

&lt;P&gt;So how to calculate it????&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 13:38:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395464#M6707</guid>
      <dc:creator>krishnab</dc:creator>
      <dc:date>2018-05-10T13:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395465#M6708</link>
      <description>&lt;P&gt;In your base search add &lt;CODE&gt;(state="Pending" OR state="Resolved")&lt;/CODE&gt;, then use the &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Transaction"&gt;transaction command&lt;/A&gt; as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| transaction &amp;lt;field(s) to group by&amp;gt; startswith="Pending" endswith="Resolved"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The transaction command automatically gives you a "duration" field in seconds.&lt;/P&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 14:10:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395465#M6708</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2018-05-10T14:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395466#M6709</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Search Here:
| search (state="Pending" OR state="Resolved")
| stats range(_time) AS duration BY number
| eval duration=tostring(duration, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 May 2018 14:11:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395466#M6709</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-10T14:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395467#M6710</link>
      <description>&lt;P&gt;Or like this (gives you options to do any kind of state-change timing all together, which the other answer does not):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Search Here
| eval PendingTime=if(state="Pending", _time, null())
| eventstats min(PendingTime) AS PendingTime BY number
| eval PendingToResolvedTime = if(state="Resolved", tostring((_time - PendingTime), "duration"), null())
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 May 2018 14:16:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395467#M6710</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-10T14:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395468#M6711</link>
      <description>&lt;P&gt;Did not know about this &lt;CODE&gt;| stats range(_time) AS duration BY number&lt;/CODE&gt;. TIL something&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 14:22:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395468#M6711</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2018-05-10T14:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395469#M6712</link>
      <description>&lt;P&gt;That's what &lt;CODE&gt;upvotes&lt;/CODE&gt; are for! &lt;span class="lia-unicode-emoji" title=":grinning_squinting_face:"&gt;😆&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 14:30:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395469#M6712</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-10T14:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395470#M6713</link>
      <description>&lt;P&gt;True, but one should NEVER use &lt;CODE&gt;transaction&lt;/CODE&gt; if there is ANY other way.  In this case there is.  The overhead and unscalability of &lt;CODE&gt;transaction&lt;/CODE&gt; means that it should be avoided at all costs.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 14:32:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395470#M6713</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-05-10T14:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395471#M6714</link>
      <description>&lt;P&gt;Another approach (A generic one which allows finding duration between any two states)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search 
| eval temp=dv_cmdb_ci."##".number
| chart max(_time) over temp by state
| rex field=temp "(?&amp;lt;dv_cmdb_ci&amp;gt;.+)##(?&amp;lt;number&amp;gt;.+)" | fields - temp
| table dv_cmdb_ci number *
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Above will give time for each state for a host-ticket combination as a column. You can now add eval statements to find duration between any two states, by adding it to end of above search, e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;above search
| eval PendingToResolvedDuration=Resolved-Pending
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any state value which has spaces in them, enclose them in single quotes. (e.g. &lt;CODE&gt;| eval WIPtoResolved=Resolved-'Work In Progress'&lt;/CODE&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 15:53:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395471#M6714</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-05-10T15:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate time difference in statistics using another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395472#M6715</link>
      <description>&lt;P&gt;Never knew there was range(_time) option..Thanks..&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 07:18:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-to-calculate-time-difference-in-statistics-using-another/m-p/395472#M6715</guid>
      <dc:creator>krishnab</dc:creator>
      <dc:date>2018-05-11T07:18:54Z</dc:date>
    </item>
  </channel>
</rss>

