RHQ, the common services project for infrastructure management

  Dashboard > RHQ-Project > Response Time Filter
  RHQ-Project Log In | Sign Up   View a printable version of the current page.  
  Response Time Filter
Added by John Mazzitelli , last edited by John Mazzitelli on Feb 29, 2008
Labels: 
(None)

Response Time Filter

In order to measure response times from web applications, you need to install a servlet filter on the target web container

Generic Install

The installation consists of two parts:

  • add an additional java library
  • Update the servlet container configuration

Library installation

You need to copy the file rhq-rtfilter-<version>.jar to a directory in the classpath of your servlet container. The specifics for containers are described below. This library can be built from the RHQ source at http://svn.rhq-project.org/repos/rhq/trunk/modules/helpers/rtfilter/.

Configuration update

The configuration update consists of two additions to the servlet container configuration. The exact file is mentioned below in the section for individual servlet containers. The two parts are a <filter/> and <filter-mapping/> directive.

For the <filter/> directive, you can just use the first one if you are happy with the defaults. If you want to change parameters, you can use the enhanced one. Remember to use only one of both.

Previous to Servlet version 2.4 you must be careful to put the directives next to other directives of the same kind. Filter related directives go in front of the <servlet/> sections.

You may want to put the <filter/> in front of other filters so that the RHQ Response Time Filter can take their delay into account as well.

Simplest <filter/> section
<filter>
  <filter-name>RHQRtFilter</filter-name>
  <filter-class>org.rhq.helpers.rtfilter.filter.RtFilter</filter-class>
</filter>
Enhanced <filter/> section
<filter>
  <filter-name>RHQRtFilter</filter-name>
  <filter-class>org.rhq.helpers.rtfilter.filter.RtFilter</filter-class>
  <init-param>
    <description>Shall the filter directly chop off the query parameters from the URL? Default is true.</description>
    <param-name>chopQueryString</param-name>
    <param-value>true</param-value>
  </init-param>
  <init-param>
    <description>Directory where logs are written to</description>
    <param-name>logDirectory</param-name>
    <param-value>/tmp</param-value>
  </init-param>
  <init-param>
    <description>Prefix to written logfile names</description>
    <param-name>logFilePrefix</param-name>
    <param-value>localhost_7080_</param-value>
  </init-param>
  <init-param>
    <description>Patterns that should not be logged</description>
    <param-name>dontLogRegEx</param-name>
    <param-value></param-value>
  </init-param>
  <init-param>
    <description>Should the dontLog pattern be applied to the URI only?</description>     
    <param-name>matchOnUriOnly</param-name>
    <param-value>true</param-value>
  </init-param>
  <init-param>
    <description>How many seconds between auto flushes of the logfile</description>
    <param-name>timeBetweenFlushesInSec</param-name>
    <param-value>73</param-value>
  </init-param>
  <init-param>
    <description>How many lines shall be written to the logfiles before a flush</description>
    <param-name>flushAfterLines</param-name>
    <param-value>13</param-value>
  </init-param>
  <init-param>
    <description>The maximum allowed size, in bytes, of the logfiles; if a logfile exceeds this limit, the filter will truncate it; the default value is 5242880 (5 MB)</description>
    <param-name>maxLogFileSize</param-name>
    <param-value>5242880</param-value>
  </init-param>
</filter>

and

<filter-mapping>
   <filter-name>RHQRtFilter</filter-name>
   <url-pattern>/*</url-pattern>
</filter-mapping>

If your Servlet container's Servlet version is below Servlet 2.4, you will need to place it in the correct section/order in the file - otherwise your servlet container will not start.

Description of init parameters

  • chopQueryString: Only the URI part of a query will be logged if this parameter is set to true. Otherwise the whole query line will be logged. Default is true.
  • logDirectory: The directory where the logfiles will be written to. Default setting is {jboss.server.log.dir}/rt/ (usually server/xxx/log/rt). If this property is not defined, the fallback is {java.io.tmpdir}/rt/ (/tmp/ on Unix, and ~/Application Data/Local Settings/Temp – check the TEMP environment variable) is used. If you specify this init parameter, no directory rt/ will be created, but the directory you have provided will be taken literally.
  • logFilePrefix: A prefix that is put in front of the logfile names. Default is the empty string.
  • dontLogRegEx: A regular expression that is applied to query strings. See java.util.regex.Pattern. If the parameter is not given or an empty string, no pattern is applied.
  • matchOnUriOnly: Should the dontLogRegEx be applied to the URI part of the query (true) or to the whole query string (false). Default is true.
  • timeBetweenFlushesInSec: Log lines are buffered by default. When the given number of seconds have passed and a new request is received, the buffered lines will be flushed to disk even if the number of lines to flush after (see next point) is not yet reached.. Default are 60 sec (1 Minute).
  • flushAfterLines: Log lines are buffered by default. When the given number of lines have been buffered, they are flushed to disk. Default is 10 lines.
  • maxLogFileSize: The maximum allowed size, in bytes, of the logfiles; if a logfile exceeds this limit, the filter will truncate it; the default value is 5242880 (5 MB).

Specific install instructions for various containers

JBoss AS with embedded Servlet containers

Copy the jar file to the lib directory at JBOSS_HOME/server/<config>/lib/

Servlet container version Example Filter configuration file
Tomcat 6 JBoss 4.2, JBoss EAP JBOSS_HOME/server/<config>/deploy/jboss-web.deployer/conf/web.xml.
Tomcat 5.5 JBoss 4.0.2 JBOSS_HOME/server/<config>/deploy/jbossweb-tomcat55.sar/conf/web.xml.
Tomcat 5.0 JBoss 3.2.6 JBOSS_HOME/server/<config>/deploy/jbossweb-tomcat50.sar/conf/web.xml.
Tomcat 4.1 JBoss 3.2.3 JBOSS_HOME/server/<config>/deploy/jbossweb-tomcat41.sar/web.xml.
Powered by a free Atlassian Confluence Open Source Project License granted to Hyperic HQ. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators