Tomcat
The Apache Tomcat source collects metrics from a Tomcat server over JMX and reads its access and catalina log files. Metrics are scraped through the OpenTelemetry JMX metrics gathering jar against an enabled JMX remote endpoint, while logs are read from the configured file paths and optionally parsed into structured fields.
Supported Telemetry Types
Linux
✓
✓
Windows
✓
✓
macOS
✓
✓
Prerequisites
For metrics, the target Tomcat JVM must have JMX remote enabled and reachable from the collector host. Enable it by adding the JMX flags to CATALINA_OPTS (typically in setenv.sh / setenv.bat), for example:
-Dcom.sun.management.jmxremote.port=9012
-Dcom.sun.management.jmxremote.rmi.port=9012
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=falseSet com.sun.management.jmxremote.rmi.port explicitly so the port is fixed (otherwise the JMX adaptor picks one at random, which breaks firewall configuration). The collector host must be able to reach the configured address and port. See the official Monitoring and Managing Tomcat documentation for details. The collector also requires the OpenTelemetry JMX metrics jar to be installed at the configured jar path.
For logs, Tomcat must be writing the relevant files and the collector must run where it can read those paths (or the files must be shipped to it). Access logging is produced by Tomcat's Access Log Valve, configured in server.xml; see the official Valve Component reference. The default paths read by this source are /usr/local/tomcat/logs/localhost_access_log.*.txt for access logs and /usr/local/tomcat/logs/catalina.out for catalina logs. Adjust them to match your installation.
Configuration

General
Choose Telemetry Type
Telemetry Selector
No
["Logs", "Metrics"]
Which signals this source collects: Logs, Metrics, or both. Parameters below are relevant only when their signal is selected.
Logs
Access Logs
Boolean
No
true
Enable collection of Tomcat access logs.
Access Log Path(s)
Strings
Yes
/usr/local/tomcat/logs/localhost_access_log.*.txt
File paths to access logs. Relevant when Access Logs is enabled.
Catalina Logs
Boolean
No
true
Enable collection of Tomcat catalina logs.
Catalina Log Path(s)
Strings
Yes
/usr/local/tomcat/logs/catalina.out
File paths to catalina logs. Relevant when Catalina Logs is enabled.
Metrics
Address
String
No
localhost
IP address or hostname to scrape for Tomcat metrics.
Port
Integer
No
9012
Port to scrape for Tomcat metrics.
Advanced
Parse To
Enum: body, attributes
No
body
Parse structured log parts to either body or attributes. Relevant when Logs is selected.
Start At
Enum: beginning, end
No
end
Start reading logs from beginning or end. Relevant when Logs is selected.
Timezone
Timezone
No
UTC
The timezone to use when parsing log timestamps. Relevant when Logs is selected.
Parse
Boolean
No
true
Parses the log fields into structured data. Relevant when Logs is selected.
JMX Metrics Collection Jar Path
String
No
/opt/opentelemetry-java-contrib-jmx-metrics.jar
Full path to the JMX metrics jar. Relevant when Metrics is selected.
Collection Interval
Integer
No
60
How often (seconds) to scrape for metrics. Relevant when Metrics is selected.
Examples
Collect metrics and logs from a local Tomcat
This source scrapes JMX metrics from a Tomcat server on localhost:9012 and reads both the access and catalina logs from their default locations.
Configuration Tips
The JMX
Port(default9012) must match thecom.sun.management.jmxremote.portvalue set inCATALINA_OPTS. Set the RMI port to the same value to keep it fixed.If JMX authentication or TLS is enabled on Tomcat, configure the JMX gathering jar accordingly; the defaults assume
authenticate=falseandssl=false.Use the telemetry-type selector to scope the source: disable Metrics if you only ship logs, or disable Logs (or one of the access/catalina toggles) if you only want metrics.
Troubleshooting
No metrics appear
Symptoms: the source produces no Tomcat metrics.
Solutions:
Confirm JMX remote is enabled in
CATALINA_OPTSand that Tomcat was restarted after the change.Verify the configured Address and Port match the JMX/RMI port and that the collector host can reach it.
Confirm the JMX metrics jar exists at the configured jar path.
Connection refused
Symptoms: the collector logs a connection error when scraping.
Solutions:
Check that the JMX port is listening and not blocked by a firewall.
Ensure
com.sun.management.jmxremote.rmi.portis set so the port stays fixed.
No logs appear
Symptoms: access or catalina logs are not collected.
Solutions:
Verify the configured log paths exist and that the collector user can read them.
Confirm the Access Log Valve is configured in
server.xmlso access logs are being written.If logs are being written but not parsed as expected, check that Parse is enabled and the log format matches.
Standalone Source
Related Resources
Last updated
Was this helpful?