<?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 duration of two events with same fields that contain the same value occurred at different time in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410565#M118489</link>
    <description>&lt;P&gt;Hey David,&lt;BR /&gt;
I tried this also , by doing this  , event having same values occurred at different time gets grouped and duration takes the start time as first Open state and  last resolved  state of last occurrence of  that event&lt;BR /&gt;
For example :&lt;BR /&gt;
_time   ID  Title   Severity    State   hostname&lt;BR /&gt;
29-05-2019 08:02    450 Slow disk   BBB OPEN    host1&lt;BR /&gt;
29-05-2019 08:06    450 Slow disk   BBB OPEN    host1&lt;BR /&gt;
18-04-2019 18:49    450 Slow disk   BBB RESOLVED    host1&lt;BR /&gt;
18-04-2019 18:43    450 Slow disk   BBB OPEN    host1&lt;BR /&gt;
BY using above trick , durationMinutes showing for these events as one &lt;BR /&gt;
ID      Title   Severity    State       hostname    durationMinutes &lt;BR /&gt;
450  Slow disk  BBB     RESOLVED    host1   58392.36666666667 &lt;/P&gt;

&lt;P&gt;I want both events should be counted as individual . Please suggest some other way.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jun 2019 16:59:05 GMT</pubDate>
    <dc:creator>avni26</dc:creator>
    <dc:date>2019-06-10T16:59:05Z</dc:date>
    <item>
      <title>How to calculate duration of two events with same fields that contain the same value occurred at different time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410561#M118485</link>
      <description>&lt;P&gt;I have following sample events of a problem having field State open and Resolved.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time              ID    Title      Severity    State    hostname
08-05-2019 13:14    450 Monitoring   AAA         OPEN     host2
08-05-2019 13:15    450 Monitoring   AAA         RESOLVED  host2
16-05-2019 18:58    660 Slow disk   BBB      RESOLVED  host1
16-05-2019 18:09    660 Slow disk   BBB      OPEN     host1
29-05-2019 08:02    450 Slow disk   BBB      OPEN     host3
29-05-2019 08:06    450 Slow disk   BBB      RESOLVED  host3
18-04-2019 18:43    450 Slow disk   BBB      OPEN     host3
25-03-2019 18:30    660 Slow disk   BBB      RESOLVED  host1
25-03-2019 18:19    660 Slow disk   BBB      OPEN     host1
18-04-2019 18:49    450    Slow disk    BBB         RESOLVED  host3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to calculate the duration of each problem at every occurrence and want to display results in single table.&lt;BR /&gt;
    For example : Result should be like below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time             ID     Title      Severity   State       hostname   duration(Min)
18-04-2019 18:49   450    Slow disk    BBB        RESOLVED  host3      3.00
08-05-2019 13:15   450    Monitoring   AAA        RESOLVED    host2      1.02
29-05-2019 08:06   450  Slow disk   BBB     RESOLVED    host3      4
25-03-2019 18:30   660  Slow disk   BBB     RESOLVED    host1      11
16-05-2019 18:58   660  Slow disk   BBB     RESOLVED    host1      49
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please suggest.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 18:13:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410561#M118485</guid>
      <dc:creator>avni26</dc:creator>
      <dc:date>2019-06-07T18:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of two events with same fields that contain the same value occurred at different time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410562#M118486</link>
      <description>&lt;P&gt;You can use transaction for this.  You would use both ID and host as the key:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[BASE SEARCH]
| transaction ID hostname startswith="(State=OPEN)" endswith="(State=RESOLVED)"
| stats latest(_time) as time  latest(Title) as Title latest(duration) as duration by ID hostname
| eval time = strftime(time,"%Y-%m-%d %H:%M:%S.%3N") 
| eval duration = duration/60 | sort duration
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try something like this.  You will probably want to use a table command to format the fields in the correct order at the end of the search.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 18:46:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410562#M118486</guid>
      <dc:creator>kmorris_splunk</dc:creator>
      <dc:date>2019-06-07T18:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of two events with same fields that contain the same value occurred at different time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410563#M118487</link>
      <description>&lt;P&gt;Hi Kmorris,&lt;/P&gt;

&lt;P&gt;I already tried this, from transaction its not fetching all desired output . There is some  Problem  events also exist whose State is only "OPEN" or only RESOLVED . Those events count are not coming after using this. &lt;BR /&gt;
And also due to Transaction command  ,  Its taking lots of time to load. &lt;BR /&gt;
Can't it be done by some other way without using Transaction.&lt;/P&gt;

&lt;P&gt;Please suggest .&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 06:21:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410563#M118487</guid>
      <dc:creator>avni26</dc:creator>
      <dc:date>2019-06-10T06:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of two events with same fields that contain the same value occurred at different time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410564#M118488</link>
      <description>&lt;P&gt;Hi @avni26,&lt;/P&gt;

&lt;P&gt;This will do the trick :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Yoursearch 
| stats earliest(_time) as start, latest(_time) as end, values(severity) as severity,values(Title) as Title, last(State) as State by hostname, ID
|eval durationMinutes=(end-start)/60
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if that helps.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 07:57:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410564#M118488</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-06-10T07:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of two events with same fields that contain the same value occurred at different time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410565#M118489</link>
      <description>&lt;P&gt;Hey David,&lt;BR /&gt;
I tried this also , by doing this  , event having same values occurred at different time gets grouped and duration takes the start time as first Open state and  last resolved  state of last occurrence of  that event&lt;BR /&gt;
For example :&lt;BR /&gt;
_time   ID  Title   Severity    State   hostname&lt;BR /&gt;
29-05-2019 08:02    450 Slow disk   BBB OPEN    host1&lt;BR /&gt;
29-05-2019 08:06    450 Slow disk   BBB OPEN    host1&lt;BR /&gt;
18-04-2019 18:49    450 Slow disk   BBB RESOLVED    host1&lt;BR /&gt;
18-04-2019 18:43    450 Slow disk   BBB OPEN    host1&lt;BR /&gt;
BY using above trick , durationMinutes showing for these events as one &lt;BR /&gt;
ID      Title   Severity    State       hostname    durationMinutes &lt;BR /&gt;
450  Slow disk  BBB     RESOLVED    host1   58392.36666666667 &lt;/P&gt;

&lt;P&gt;I want both events should be counted as individual . Please suggest some other way.&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 16:59:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410565#M118489</guid>
      <dc:creator>avni26</dc:creator>
      <dc:date>2019-06-10T16:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate duration of two events with same fields that contain the same value occurred at different time</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410566#M118490</link>
      <description>&lt;P&gt;@DavidHourani @kmorris Sorry for delay response. &lt;BR /&gt;
Thank you so much it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 06:22:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-duration-of-two-events-with-same-fields-that/m-p/410566#M118490</guid>
      <dc:creator>avni26</dc:creator>
      <dc:date>2019-07-11T06:22:19Z</dc:date>
    </item>
  </channel>
</rss>

