How to Get JMX Prometheus Exporter Working in Tomcat 10
For a webmaster or site reliability engineer, monitoring the underlying infrastructure of a web application is vital for long-term SEO health. If your Tomcat 10 server suffers from memory leaks or thread exhaustion, your site speed will tank, negatively impacting your Core Web Vitals. Using the JMX Prometheus Exporter allows you to scrape internal JVM and Tomcat metrics into a Prometheus/Grafana stack for real-time observability.
Here is the technical workflow to integrate the Prometheus JMX Exporter as a Java Agent in Tomcat 10.
1. Download the JMX Exporter Jar
The exporter runs as a javaagent. You need to download the latest release of the jmx_prometheus_javaagent.jar from the official Prometheus GitHub repository.
- Place the jar in a stable directory, such as
/opt/tomcat/bin/or a dedicated/opt/prometheus/folder. - Ensure the Tomcat user has read and execute permissions for this file.
2. Create the Configuration YAML
The exporter requires a configuration file to define which JMX MBeans to scrape and how to format them. Create a file named config.yaml in the same directory as your jar.
---
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
- pattern: 'Catalina<type=GlobalRequestProcessor, name="(\w+-\w+)-(\d+)"><>(\w+):'
name: tomcat_request_processor_$3
labels:
connector: "$1"
port: "$2"
- pattern: 'Catalina<type=ThreadPool, name="(\w+-\w+)-(\d+)"><>(\w+):'
name: tomcat_threadpool_$3
labels:
connector: "$1"
port: "$2"
3. Configure Tomcat Environment Variables
To load the agent, you must modify the CATALINA_OPTS or JAVA_OPTS variable. In Tomcat 10, the best practice is to create or edit the setenv.sh (Linux) or setenv.bat (Windows) file in the /bin directory.
Linux (setenv.sh):
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/prometheus/jmx_prometheus_javaagent-1.0.1.jar=8080:/opt/prometheus/config.yaml"
Note: In this example, 8080 is the port where Prometheus will scrape metrics. Ensure this does not conflict with Tomcat's own HTTP port.
4. Firewall and Scraping
Once you restart Tomcat 10, the agent will begin exposing metrics at http://your-server-ip:8080/metrics.
- Firewall: Open the port (e.g., 8080) for your Prometheus server's IP address.
- Prometheus Config: Add a new job to your
prometheus.yml:
scrape_configs:
- job_name: 'tomcat-10'
static_configs:
- targets: ['localhost:8080']
5. Why This Matters for SEO
From an SEO and webmaster perspective, infrastructure monitoring is proactive ranking protection. The Google Search web application penalizes sites with high TTFB (Time to First Byte).
- Thread Monitoring: If
tomcat_threadpool_currentthreadsbusyreaches its max, your server will queue requests, causing massive latency spikes. - Garbage Collection: Monitoring
jvm_gc_collection_seconds_sumhelps identify "Stop the World" events that freeze your web application and hurt user experience scores. - Request Processing: Tracking
tomcat_request_processor_errorcounthelps you catch 5xx errors before they appear as "Crawl Anomalies" in Google Search Console.
Conclusion
Getting the JMX Prometheus Exporter working in Tomcat 10 provides the visibility needed to scale a high-traffic web application. By surfacing JVM and Catalina metrics, you can ensure your server remains performant, keeping your SEO rankings stable and your users happy. Once configured, use Grafana to build a dashboard that correlates server load with your search engine impression data for a full-stack view of your site's health.
