<?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: getting the average time from multiple transactions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/getting-the-average-time-from-multiple-transactions/m-p/500870#M139460</link>
    <description>&lt;P&gt;Perhaps you could &lt;CODE&gt;| eval _time = actual_important_log_time&lt;/CODE&gt; before &lt;CODE&gt;| transaction&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Mar 2020 17:03:47 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-03-26T17:03:47Z</dc:date>
    <item>
      <title>getting the average time from multiple transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/getting-the-average-time-from-multiple-transactions/m-p/500869#M139459</link>
      <description>&lt;P&gt;So I have some data in the format of &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time                | UUID           |  event_name_status            | actual_important_log_time 

---------------------------------------------------------------------------------------------------------------
2020-03-26T12:00:00 | 123456789      |  car_end                      | 2020-03-25T16:50:30
2020-03-26T12:00:00 | 123456789      |  car_mid                      | 2020-03-25T16:40:30
2020-03-26T12:00:00 | 123456789      |  car_start                    | 2020-03-25T16:30:30
2020-03-26T12:00:00 | 123456788      |  car_end                      | 2020-03-25T15:50:30
2020-03-26T12:00:00 | 123456788      |  car_mid                      | 2020-03-25T15:20:30
2020-03-26T12:00:00 | 123456788      |  car_start                    | 2020-03-25T14:50:30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which Is a consistent pattern with each transaction having a start, mid and end with a different UID per transaction (also different vehichles for other transactions).&lt;/P&gt;

&lt;P&gt;I currently group them into transactions using the following search command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;* | transaction UUID startswith="car_start" endswith="car_end"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which groups the transactions showing how many there were in the last X length of time (could be hundreds/thousands in a day.&lt;/P&gt;

&lt;P&gt;I need to get the duration of each transaction using the &lt;STRONG&gt;actual_important_log_time&lt;/STRONG&gt; field and then use these values to get the average time the &lt;STRONG&gt;car&lt;/STRONG&gt; transaction took. (this will then go in a dashboard&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:43:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/getting-the-average-time-from-multiple-transactions/m-p/500869#M139459</guid>
      <dc:creator>brunelstudent</dc:creator>
      <dc:date>2020-09-30T04:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: getting the average time from multiple transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/getting-the-average-time-from-multiple-transactions/m-p/500870#M139460</link>
      <description>&lt;P&gt;Perhaps you could &lt;CODE&gt;| eval _time = actual_important_log_time&lt;/CODE&gt; before &lt;CODE&gt;| transaction&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 17:03:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/getting-the-average-time-from-multiple-transactions/m-p/500870#M139460</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-03-26T17:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: getting the average time from multiple transactions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/getting-the-average-time-from-multiple-transactions/m-p/500871#M139461</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval _raw="Time                 UUID        event_name_status           actual_important_log_time 
2020-03-26T12:00:00  123456789   car_end                     2020-03-25T16:50:30
2020-03-26T12:00:00  123456789   car_mid                     2020-03-25T16:40:30
2020-03-26T12:00:00  123456789   car_start                   2020-03-25T16:30:30
2020-03-26T12:00:00  123456788   car_end                     2020-03-25T15:50:30
2020-03-26T12:00:00  123456788   car_mid                     2020-03-25T15:20:30
2020-03-26T12:00:00  123456788   car_start                   2020-03-25T14:50:30"
| multikv forceheader=1
| fields - _raw linecount

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"
| rename COMMENT AS "The next line may or may not be necessary"
| eval _time = strptime(Time, "%Y-%m-%dT%H:%M:%S")

| eval actual_important_log_time =strptime(actual_important_log_time, "%Y-%m-%dT%H:%M:%S")
| stats min(_time) AS _time range(_time) AS time_duration range(actual_important_log_time) AS real_duration list(event_name_status) AS event_name_status BY UUID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Mar 2020 20:34:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/getting-the-average-time-from-multiple-transactions/m-p/500871#M139461</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-26T20:34:44Z</dc:date>
    </item>
  </channel>
</rss>

