<?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: Apache Avg Response Time in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320902#M59883</link>
    <description>&lt;P&gt;to verify that Apache is actually logging the micro seconds check your httpd.conf file for an entry that is similar to the below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;LogFormat "\"%{Host}i\" %h \"%{X-Forwarded-For}i\" %l %u %t \"%r\" %&amp;gt;s %b %T %D \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-icErrorCode}o\"" combined
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;%D&lt;/CODE&gt; is the critical piece.  That is the configuration option that tells apache to include the micro seconds that it took to execute the command.&lt;/P&gt;

&lt;P&gt;You can see all the apache configuration options here .  &lt;A href="http://httpd.apache.org/docs/current/mod/mod_log_config.html"&gt;http://httpd.apache.org/docs/current/mod/mod_log_config.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Feb 2017 15:29:32 GMT</pubDate>
    <dc:creator>dbcase</dc:creator>
    <dc:date>2017-02-21T15:29:32Z</dc:date>
    <item>
      <title>Apache Avg Response Time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320900#M59881</link>
      <description>&lt;P&gt;Hi everyone, I have exhausted the guess and click on this.&lt;/P&gt;

&lt;P&gt;I'm learning Splunk by following the book Operational intelligence Cookbook Volume 2 and I have hit a wall.&lt;BR /&gt;
The Recipe I'm working on is supposed to chart an applications functional statics, here is the code in the book.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index = main sourcetype = log4j 
| eval mem_used_MB =( mem_used/ 1024)/ 1024 
| eval mem_total_MB =( mem_total/ 1024)/ 1024 
| timechart span = 1m values( mem_total_MB) AS Total_Mem_Avail_MB, count AS Total_Calls, avg( mem_used_MB) AS Avg_Mem_Used_MB, avg( response_time) AS Avg_Response_Time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This works fine except that AVG_Response_Time produces no values.&lt;/P&gt;

&lt;P&gt;I changed the code someone to also use sourcetype="access_combined" and instead of AS Avg_Response_Time I changed it to just  avg_response and added the round function. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main sourcetype=log4j OR sourcetype="access_combined" 
| eval mem_used_MB=(mem_used/1024)/1024 
| eval mem_total_MB=(mem_total/1024)/1024 **
|eval avg_response=round(response/1000,2)** 
|timechart span=1m values(mem_total_MB) AS Total_Mem_Avail_MB, count AS Total_Calls, avg(mem_used_MB) AS Avg_Mem_Used_MB, avg(avg_response) As avg_response_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now the avg_response responses times show up in the statistics output but I'm wondering why the books code did not work? Why did I have to add another sourcetype?&lt;BR /&gt;
Should I have added a field "response_time" in field extractor?&lt;/P&gt;

&lt;P&gt;What am I missing?&lt;/P&gt;

&lt;P&gt;Thanks for any help&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:59:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320900#M59881</guid>
      <dc:creator>ChicagoKid</dc:creator>
      <dc:date>2020-09-29T12:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Avg Response Time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320901#M59882</link>
      <description>&lt;P&gt;It could be that field response_time is not extracted (correctly) in sourcetype=log4j or the raw data for log4j doesn't contain the response_time at correct place or not present at all. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:00:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320901#M59882</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T13:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Avg Response Time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320902#M59883</link>
      <description>&lt;P&gt;to verify that Apache is actually logging the micro seconds check your httpd.conf file for an entry that is similar to the below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;LogFormat "\"%{Host}i\" %h \"%{X-Forwarded-For}i\" %l %u %t \"%r\" %&amp;gt;s %b %T %D \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-icErrorCode}o\"" combined
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;%D&lt;/CODE&gt; is the critical piece.  That is the configuration option that tells apache to include the micro seconds that it took to execute the command.&lt;/P&gt;

&lt;P&gt;You can see all the apache configuration options here .  &lt;A href="http://httpd.apache.org/docs/current/mod/mod_log_config.html"&gt;http://httpd.apache.org/docs/current/mod/mod_log_config.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 15:29:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320902#M59883</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-02-21T15:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Avg Response Time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320903#M59884</link>
      <description>&lt;P&gt;You need to make sure your data has the data for the fields you're trying to use - and that they are being extracted correctly - before you can do analytics operations against them.  Echoing the suggestion of @dbcase, for &lt;CODE&gt;sourcetype=access_combined&lt;/CODE&gt; (the default Apache log format) there is no existing "time spent" or "duration" or "response time" or anything like that.  You would need to make sure it gets added.&lt;/P&gt;

&lt;P&gt;Splunk internally has some log file formats that are substantially similar to &lt;CODE&gt;access_combined&lt;/CODE&gt; like &lt;CODE&gt;splunkd_web_access&lt;/CODE&gt; that include more detail in the log events and additional field extractions to get the fields from that data.  For example:&lt;/P&gt;

&lt;P&gt;Here's 1 event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;127.0.0.1 - admin [21/Feb/2017:09:33:37.991 -0600] "GET /services/search/timeparser/tz HTTP/1.0" 200 3390 - - - 1ms
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the props.conf for that sourcetype:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[splunkd_access]
maxDist = 28
MAX_TIMESTAMP_LOOKAHEAD = 128
REPORT-access = access-extractions, extract_spent
SHOULD_LINEMERGE = False
TIME_PREFIX = \[
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the transforms.conf for &lt;CODE&gt;extract_spent&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_spent]
REGEX   = \s(?P&amp;lt;spent&amp;gt;\d+(\.\d+)?)ms$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With &lt;CODE&gt;spent&lt;/CODE&gt; being in the data (1ms) and being properly extracted, it's easy for me now to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=_internal sourcetype=splunkd_access | stats avg(spent)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With Apache logs in general, what I would personally suggest is if you're going to modify the format of &lt;CODE&gt;access_combined&lt;/CODE&gt;, then add new fields to the END, and do them as &lt;CODE&gt;key=value&lt;/CODE&gt;.  Then you don't have to change anything and Splunk just picks it up.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 15:48:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320903#M59884</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2017-02-21T15:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Avg Response Time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320904#M59885</link>
      <description>&lt;P&gt;Thanks dbcase and dwaddle for your help. &lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 15:44:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320904#M59885</guid>
      <dc:creator>ChicagoKid</dc:creator>
      <dc:date>2017-02-22T15:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Apache Avg Response Time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320905#M59886</link>
      <description>&lt;P&gt;you are welcome!  &lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2017 16:05:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Apache-Avg-Response-Time/m-p/320905#M59886</guid>
      <dc:creator>dbcase</dc:creator>
      <dc:date>2017-02-22T16:05:27Z</dc:date>
    </item>
  </channel>
</rss>

