<?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: Help with search for average response time based on TotalTime value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490676#M137006</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="2020-03-11 08:23:55,141 - [UserId=xyz | UserName=abc |  INFO  
                     INFO  APIName=\"REPORT SEARCH\",Stage=\"exit\",StartTime=\"2020-03-11 08:23:55.101\",EndTime=\"2020-03-11 08:23:55.141\",**TotalTime**=\"40 Milliseconds\",XBAPILatency=\"0 Milliseconds\",XBLatency=\"40 Milliseconds\",XBMessage=\"REPORT SEARCH API response was 40 Milliseconds.\",RequestStatus=\"Success\":::2020-03-11 08:23:55,151 - [UserId=xyz | UserName=abc |  INFO  
                     INFO  APIName=\"REPORT SEARCH\",Stage=\"exit\",StartTime=\"2020-03-11 08:23:55.101\",EndTime=\"2020-03-11 08:23:55.151\",**TotalTime**=\"50 Milliseconds\",XBAPILatency=\"0 Milliseconds\",XBLatency=\"50 Milliseconds\",XBMessage=\"REPORT SEARCH API response was 50 Milliseconds.\",RequestStatus=\"Success\":::2020-03-11 08:23:55,161 - [UserId=xyz | UserName=abc |  INFO  
                     INFO  APIName=\"REPORT SEARCH\",Stage=\"exit\",StartTime=\"2020-03-11 08:23:55.101\",EndTime=\"2020-03-11 08:23:55.161\",**TotalTime**=\"60 Milliseconds\",XBAPILatency=\"0 Milliseconds\",XBLatency=\"60 Milliseconds\",XBMessage=\"REPORT SEARCH API response was 60 Milliseconds.\",RequestStatus=\"Success\"" 
| makemv delim=":::" raw 
| mvexpand raw 
| rename raw AS _raw 
| kv

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| rex field=TotalTime "^(?&amp;lt;TT_magnitude&amp;gt;\d+)\s*(?&amp;lt;TT_units&amp;gt;.*)$"
| eval TT = TT_magnitude * case(
   TT_units = "Milliseconds", 1/1000,
   TT_units = "Centiseconds", 1/100,
   TT_units = "Seconds", 1,
   true(), 0)
| stats avg(TT) AS avg_TotalTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 11 Mar 2020 16:36:39 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2020-03-11T16:36:39Z</dc:date>
    <item>
      <title>Help with search for average response time based on TotalTime value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490674#M137004</link>
      <description>&lt;P&gt;I have multiple log events like below based on my search criteria-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2020-03-11 08:23:55,141 - [UserId=xyz | UserName=abc |  INFO  
                    INFO  APIName="REPORT SEARCH",Stage="exit",StartTime="2020-03-11 08:23:55.101",EndTime="2020-03-11 08:23:55.141",**TotalTime**="40 Milliseconds",XBAPILatency="0 Milliseconds",XBLatency="40 Milliseconds",XBMessage="REPORT SEARCH API response was 40 Milliseconds.",RequestStatus="Success"

2020-03-11 08:23:55,151 - [UserId=xyz | UserName=abc |  INFO  
                    INFO  APIName="REPORT SEARCH",Stage="exit",StartTime="2020-03-11 08:23:55.101",EndTime="2020-03-11 08:23:55.151",**TotalTime**="50 Milliseconds",XBAPILatency="0 Milliseconds",XBLatency="50 Milliseconds",XBMessage="REPORT SEARCH API response was 50 Milliseconds.",RequestStatus="Success"


2020-03-11 08:23:55,161 - [UserId=xyz | UserName=abc |  INFO  
                    INFO  APIName="REPORT SEARCH",Stage="exit",StartTime="2020-03-11 08:23:55.101",EndTime="2020-03-11 08:23:55.161",**TotalTime**="60 Milliseconds",XBAPILatency="0 Milliseconds",XBLatency="60 Milliseconds",XBMessage="REPORT SEARCH API response was 60 Milliseconds.",RequestStatus="Success"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to build a Splunk query which will give me average response time based on &lt;STRONG&gt;TotalTime&lt;/STRONG&gt; value.&lt;/P&gt;

&lt;P&gt;I tried to do so by | stats avg(TotalTime)  but no results are showing as the value contains a string (Milliseconds) as well.&lt;BR /&gt;
Can someone please help me with this as I am new to Splunk tool?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 13:39:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490674#M137004</guid>
      <dc:creator>dhirajnangar</dc:creator>
      <dc:date>2020-03-11T13:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help with search for average response time based on TotalTime value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490675#M137005</link>
      <description>&lt;P&gt;As a first cut, you can use rex to extract the value of TotalTime from the events.&lt;/P&gt;

&lt;P&gt;Something like this should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearch
| rex field=_raw \*\*TotalTime\*\*="(?&amp;lt;TotalTime&amp;gt;\d+)\sMilliseconds"
| stats avg(TotalTime)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I recommend looking at the percentile calculations rather than average.  Although avg is widely used, average can hide outliers.&lt;BR /&gt;
In your situation, I would look at the differences between average and the 50th percentile (aka &lt;EM&gt;median&lt;/EM&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; yoursearch
 | rex field=_raw \*\*TotalTime\*\*="(?&amp;lt;TotalTime&amp;gt;\d+)\sMilliseconds"
 | stats avg(TotalTime) AS Average, perc50(TotalTime) as Median
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If it looks like using Total Time is worthwhile, then move the field extraction of TotalTime to props.conf with the help of your local Splunk admin.&lt;/P&gt;

&lt;P&gt;Hope that helps!&lt;BR /&gt;
rmmiller&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 15:26:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490675#M137005</guid>
      <dc:creator>rmmiller</dc:creator>
      <dc:date>2020-03-11T15:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with search for average response time based on TotalTime value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490676#M137006</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="2020-03-11 08:23:55,141 - [UserId=xyz | UserName=abc |  INFO  
                     INFO  APIName=\"REPORT SEARCH\",Stage=\"exit\",StartTime=\"2020-03-11 08:23:55.101\",EndTime=\"2020-03-11 08:23:55.141\",**TotalTime**=\"40 Milliseconds\",XBAPILatency=\"0 Milliseconds\",XBLatency=\"40 Milliseconds\",XBMessage=\"REPORT SEARCH API response was 40 Milliseconds.\",RequestStatus=\"Success\":::2020-03-11 08:23:55,151 - [UserId=xyz | UserName=abc |  INFO  
                     INFO  APIName=\"REPORT SEARCH\",Stage=\"exit\",StartTime=\"2020-03-11 08:23:55.101\",EndTime=\"2020-03-11 08:23:55.151\",**TotalTime**=\"50 Milliseconds\",XBAPILatency=\"0 Milliseconds\",XBLatency=\"50 Milliseconds\",XBMessage=\"REPORT SEARCH API response was 50 Milliseconds.\",RequestStatus=\"Success\":::2020-03-11 08:23:55,161 - [UserId=xyz | UserName=abc |  INFO  
                     INFO  APIName=\"REPORT SEARCH\",Stage=\"exit\",StartTime=\"2020-03-11 08:23:55.101\",EndTime=\"2020-03-11 08:23:55.161\",**TotalTime**=\"60 Milliseconds\",XBAPILatency=\"0 Milliseconds\",XBLatency=\"60 Milliseconds\",XBMessage=\"REPORT SEARCH API response was 60 Milliseconds.\",RequestStatus=\"Success\"" 
| makemv delim=":::" raw 
| mvexpand raw 
| rename raw AS _raw 
| kv

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| rex field=TotalTime "^(?&amp;lt;TT_magnitude&amp;gt;\d+)\s*(?&amp;lt;TT_units&amp;gt;.*)$"
| eval TT = TT_magnitude * case(
   TT_units = "Milliseconds", 1/1000,
   TT_units = "Centiseconds", 1/100,
   TT_units = "Seconds", 1,
   true(), 0)
| stats avg(TT) AS avg_TotalTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Mar 2020 16:36:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490676#M137006</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-11T16:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: Help with search for average response time based on TotalTime value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490677#M137007</link>
      <description>&lt;P&gt;Solid!  My first instinct was to ask about the units and whether they always showed up with the same units.  You bulletproofed it!  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 17:37:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-search-for-average-response-time-based-on-TotalTime/m-p/490677#M137007</guid>
      <dc:creator>rmmiller</dc:creator>
      <dc:date>2020-03-11T17:37:22Z</dc:date>
    </item>
  </channel>
</rss>

