Tomcat metrics

The OpenTelemetry Collector provides an integration with Apache Tomcat to ingest metrics. When configured to use the JMX/Tomcat integration, the Collector fetches metrics from a target MBean server using built-in profiles for Tomcat. From there the metrics are processed and exported to Cloud Observability.

To complete the integration, you will:

  • Configure a JMX remote connection for the Collector on the Java Virtual Machine
  • Configure the JMX receiver for the Collector to ingest Tomcat metrics
  • Enable the integration by adding it to a pipeline

Prerequisites

  • Tomcat v5 or later
  • Download OpenTelemetry JMX Metric JAR release version 1.9 or later.
  • The path to the opentelemetry-jmx-metrics.jar file.
  • You’ve configured the Collector to export data to Cloud Observability.

Configure Tomcat

Configure a JMX remote connection for the Collector receiver to connect to the executing Java Virtual Machine.

This example shows JMX configuration (without authentication) by setting the CATALINA_OPTS environment variable:

1
2
3
4
export CATALINA_OPTS=-Dcom.sun.management.jmxremote \
  -Dcom.sun.management.jmxremote.port=$PORT_NUMBER \
  -Dcom.sun.management.jmxremote.ssl=false \
  -Dcom.sun.management.jmxremote.authenticate=false

For more details regarding configuring the Tomcat remote connection, see the official Tomcat documentation.

Configure the Collector receiver

Add JMX/Tomcat as a receiver and set the following:

  • jar_path: The path to the OpenTelemetry JMX metrics jar file.
  • endpoint: The endpoint of the host:port for the running application. This should be the same port used in the JMX configuration, above.
  • target_system: The metrics to collect. Values can this integration are jvm and tomcat.
1
2
3
4
5
6
7
receivers:
  jmx/tomcat:
    # Default is /opt/opentelemetry-java-contrib-jmx-metrics.jar
    jar_path: /opt/opentelemetry-jmx-metrics.jar

    endpoint: tomcat:9090 # Required.
    target_system: jvm,tomcat # Required.

The OpenTelemetry repo’s readme provides additional details about JMX configuration.

Enable the Collector receiver

Once the Tomcat receiver is configured, enable it by adding it to one or more pipelines as described in the Collector configuration documentation.

Validate metrics are reporting to Cloud Observability

You can validate that metrics are reporting to Cloud Observability on the Metrics details page in Settings.

  1. In Cloud Observability, click Settings > Metric details.

  2. Search for Tomcat metric names. Search for metric

  3. If needed, click on the metric to edit the description and how the units are displayed in Cloud Observability.

Create a dashboard for the metrics

You can create a pre-built dashboard for this integration from the Dashboard list view. Or use the Cloud Observability Terraform Provider to create a dashboard.

Additional resources

For a more complete example that’s ready to run, see the Tomcat integration in Cloud Observability OpenTelemetry Examples.

See also

Create and manage dashboards

Create alerts

Updated Dec 1, 2022