<?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 get the time duration between two scenarios? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-duration-between-two-scenarios/m-p/455246#M128747</link>
    <description>&lt;P&gt;Does something like this help for starters?  Since you're always looking for &lt;CODE&gt;UserID&lt;/CODE&gt;, I included it in the initial &lt;CODE&gt;stats&lt;/CODE&gt;. Ultimately, my logic is trying to transform like-events to a singular view by using &lt;CODE&gt;stats&lt;/CODE&gt; and grouping &lt;CODE&gt;by&lt;/CODE&gt; some unique identifier.  By using &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; functions, we can calculate  duration before calculating average.  Stats is also less taxing if you're able to fit it in:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index_name (scenariotype="scenario_1" OR scenariotype="scenario_2") 
| stats earliest(_time) as start_time, 
latest(_time) as end_time, 
latest(userID) as userID 
by service_name, scenario_type
| eval duration = end_time-start_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From there you can roll this up to more of a summary view with avg durations, etc.:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(duration) as avg_duration count(userID) as user_id by service_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might need to play around with the second stats depending on how your data looks, but try this out for now and let me know how it looks. &lt;/P&gt;</description>
    <pubDate>Wed, 12 Sep 2018 21:05:50 GMT</pubDate>
    <dc:creator>_gkollias</dc:creator>
    <dc:date>2018-09-12T21:05:50Z</dc:date>
    <item>
      <title>How to get the time duration between two scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-duration-between-two-scenarios/m-p/455245#M128746</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;

&lt;P&gt;I wanted to see if someone can help me out with this. Basically im trying to get a duration for the time in between 2 scenarios. Im trying to get how long it takes for each user to get from scenario_1 to scenario_2 by service. This is what I have so far and it seems to work when I do by individual service:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index_name (scenariotype="scenario_1" OR scenariotype="scenario_2") user_ID="*" service_name="*service_1*"
| transaction user_ID
| stats mean(duration) AS "Mean Duration(In Seconds)" by service_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Stats table shows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service_name         |       Mean Duration(In Seconds)
service_1                                   7.25
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It returns a low number and when I manually checked the mean time by user_ID, it is correct.&lt;BR /&gt;
However, when I want to get the mean duration for all services, I get a much higher number, especially for service_1 above. Keep in mind, I have 9 services Im trying to get numbers from. So basically when I run the following and dont specify a service_name or I include more than service name, i get much higher numbers for (exactly the same period of time) as the mean duration for each service(note service_1 is the same service as the above result but returning much higher number):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index_name (scenariotype="scenario_1" OR scenariotype="scenario_2") user_ID="*"
| transaction user_ID
| stats mean(duration) AS "Mean Duration(In Seconds)" by service_name    
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Stats table shows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service_name         |       Mean Duration(In Seconds)
service_1                                        189.57
service_2                                         5.75
service_3                                         5.75
service_4                                         1.35
service_5                                         6.25
service_6                                         10.40
service_7                                         4.53
service_8                                         8.78
service_9                                         6.72
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Ive also experimented with looking further back in the time and the mean duration goes up as I go further back in time if i dont specify 1 service or include more than 1 service or include all services.&lt;/P&gt;

&lt;P&gt;Hopefully I made sense and someone can help me with what am I doing wrong.&lt;/P&gt;

&lt;P&gt;thx!!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:14:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-duration-between-two-scenarios/m-p/455245#M128746</guid>
      <dc:creator>joshimeister</dc:creator>
      <dc:date>2020-09-29T21:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the time duration between two scenarios?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-duration-between-two-scenarios/m-p/455246#M128747</link>
      <description>&lt;P&gt;Does something like this help for starters?  Since you're always looking for &lt;CODE&gt;UserID&lt;/CODE&gt;, I included it in the initial &lt;CODE&gt;stats&lt;/CODE&gt;. Ultimately, my logic is trying to transform like-events to a singular view by using &lt;CODE&gt;stats&lt;/CODE&gt; and grouping &lt;CODE&gt;by&lt;/CODE&gt; some unique identifier.  By using &lt;CODE&gt;earliest&lt;/CODE&gt; and &lt;CODE&gt;latest&lt;/CODE&gt; functions, we can calculate  duration before calculating average.  Stats is also less taxing if you're able to fit it in:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=index_name (scenariotype="scenario_1" OR scenariotype="scenario_2") 
| stats earliest(_time) as start_time, 
latest(_time) as end_time, 
latest(userID) as userID 
by service_name, scenario_type
| eval duration = end_time-start_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;From there you can roll this up to more of a summary view with avg durations, etc.:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(duration) as avg_duration count(userID) as user_id by service_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might need to play around with the second stats depending on how your data looks, but try this out for now and let me know how it looks. &lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 21:05:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-the-time-duration-between-two-scenarios/m-p/455246#M128747</guid>
      <dc:creator>_gkollias</dc:creator>
      <dc:date>2018-09-12T21:05:50Z</dc:date>
    </item>
  </channel>
</rss>

