Monitoring and collecting data from Tomcat

The Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. Apache Tomcat software powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations.

More information on: http://tomcat.apache.org/

How it works

This plugin analyzes the performance of your Tomcat web server. It captures traffic rates, latencies and response codes of http requests sent to the web server by parsing the Tomcat access log file.

The plugin can optionally get global statistics (eg. the number of connections, the number of workers, etc.) by parsing the JMX proxy of the Tomcat web server.

Both the access log and JMX proxy require a bit of configuration, see next steps.

The minimal supported version of Tomcat is 7.0.

Installation

The plugin needs to be installed together with a CoScale agent, instructions on how to install the CoScale agent can be found here. If you want to monitor Tomcat inside Docker containers using CoScale, check out the instructions here.

Configuration

Configure JMX proxy

To gather global statistics the agent needs access to the JMX proxy.

Add the following lines in $CATALINA_BASE}/conf/tomcat-users.xml and fill in <username> and <password>.

<role rolename="manager"/>
<role rolename="manager-jmx"/>
<user username="<username>" password="<password>" roles="manager, manager-jmx" />

Install Tomcat manager using the following command, fill in <version> with your current Tomcat version:

apt-get install tomcat<version>-admin

Restart Tomcat to apply these changes.

Configure your Tomcat access logs

Enable the Tomcat access log format. Add the following configuration to {$CATALINA_BASE}/conf/server.xml

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" fileDateFormat="yyyy-MM-dd"
pattern="%h %v %D %T %B %l %u %t &quot;%r&quot; %s %b" />

Restart Tomcat to apply these changes.

Log format

Example of a log format configuration so that we can have all the information that we need:

%v \"%r\" %D %T %s %B

Value Original Value Remarks
Hostname %v -
Request "%r" -
Latency %D represented in milliseconds
Latency %T represented in seconds
Status Code %s -
Bytes Sent %B -

"%h %v %D %T %B %l %u %t \"%r\" %s %b %{User-Agent}i %{Referer}i"

Active checks

This plugin can be configured to perform a HTTP GET on your JBoss. This active monitoring allows us to calculate the uptime of the service and the response time of the provided URL.

A full URL (eg. http://localhost/TestPage.jsp) should be provided.

Metrics

Tomcat

Name Unit Dimensions
Tomcat active check latency s  
Tomcat active check uptime %  
Tomcat bytes received b  
Tomcat bytes sent b  
Tomcat CPU Time s  
Tomcat number of requests req  
Tomcat total number of accesses access  
Tomcat total number of hits hits  
Tomcat uptime s  
Total number of Tomcat threads busy threads  

Events

Name Description Attributes
TOMCAT service state watcher State watcher status