Server Monitoring2 min read

    How to Monitor Apache Tomcat

    Share

    Overview

    Apache Tomcat is an open-source Java servlet container and web server widely used for deploying Java web applications. Xitoring's Tomcat integration monitors JVM health, thread pool utilization, request throughput, and session states — giving you full visibility into your Java application server.

    What Can It Monitor?

    • JVM Heap Memory — Used and max heap memory
    • JVM Non-Heap Memory — Metaspace and code cache usage
    • Thread Pool — Active, busy, and max threads
    • Request Throughput — Requests processed per second
    • Request Processing Time — Average and max request duration
    • Active Sessions — Current HTTP session count
    • Error Count — HTTP error responses (4XX/5XX)
    • Bytes Sent / Received — Network throughput
    • CPU Usage — JVM process CPU utilization
    • Garbage Collection — GC count and pause times
    • Class Loading — Loaded and unloaded class counts

    Prerequisites

    Tomcat's JMX (Java Management Extensions) or the Manager API must be accessible for metric collection.

    Enable JMX Remote Access

    Add the following JVM options to your Tomcat startup configuration (setenv.sh or setenv.bat):

    export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote"
    export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.port=9090"
    export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.ssl=false"
    export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
    export CATALINA_OPTS="$CATALINA_OPTS -Djava.rmi.server.hostname=127.0.0.1"
    

    Restart Tomcat after making changes:

    sudo systemctl restart tomcat
    

    Security note: In production, enable JMX authentication and restrict access to localhost.

    How to Activate the Integration

    Run the Xitogent CLI:

    xitogent integrate
    

    Select Tomcat from the list of available integrations. When prompted, provide:

    • Host (typically 127.0.0.1)
    • Port (JMX port, e.g., 9090)

    Xitogent tests the connection and begins collecting metrics automatically.

    Setting Up Triggers

    Available trigger parameters:

    • JVM Heap / Non-Heap Memory
    • Thread Pool (active, busy, max)
    • Request Throughput / Processing Time
    • Active Sessions
    • Error Count
    • CPU Usage
    • GC Count / Pause Times

    Navigate to Triggers on your server page, select Tomcat, choose a metric, set your threshold, and configure notification channels.

    Tips

    • Monitor JVM Heap Memory — usage consistently above 80% indicates you need to increase heap size
    • Set alerts on Thread Pool Busy to detect when all threads are occupied
    • Track GC Pause Times — long pauses cause application stalls
    • Watch Active Sessions to understand user load patterns
    • Monitor Error Count to catch application exceptions early
    • Restrict JMX access to localhost for security in production environments