Solution to Tomcat indicator loss after Spring Boot Actuator upgrade
Oct 12, 2025 am 07:54 AMTomcat indicator missing phenomenon
After upgrading the spring-boot-starter-actuator dependency of a Spring Boot application to a specific version (such as 2.7.0 and higher), developers may find that the Tomcat-related metrics obtained through the /actuator/metrics endpoint are no longer complete. Specifically, some important performance monitoring indicators, such as tomcat.cache.access, tomcat.cache.hit, tomcat.global.error, etc., may disappear from the list of available indicators. These indicators are crucial for a deep understanding of the runtime status, cache efficiency, and error handling of the Tomcat server. Their absence will seriously affect the application monitoring capabilities.
Mbean registration mechanism and Actuator
Spring Boot Actuator collects application indicators in a variety of ways. For some specific indicators of underlying containers such as Tomcat, it usually relies on Java Management Extensions (JMX) MBeans. As a Java application server, Tomcat registers its internal components (such as connectors, thread pools, caches, etc.) as MBeans and exposes its runtime data through the JMX interface. Actuator can discover and use these MBeans to generate corresponding metrics.
In some Spring Boot version updates, Tomcat's MBean registration behavior may have changed or is no longer enabled by default. When Tomcat does not register its MBeans with the JMX MBeanServer, Actuator cannot discover these MBeans and naturally cannot expose the metrics associated with them. Therefore, to restore these missing Tomcat metrics, the key is to ensure that Tomcat's MBean registration mechanism is correctly enabled.
core solution
The core method to solve the problem of missing Tomcat indicators is very straightforward: explicitly enable Tomcat's MBean registration function in the configuration file of the Spring Boot application. This can be achieved by adding a configuration item in application.properties or application.yml.
Configuration example
Add the following configuration in the application.properties file:
server.tomcat.mbeanregistry.enabled=true
If your project uses application.yml, the configuration is as follows:
server: tomcat: mbeanregistry: enabled: true
After adding this configuration, when the Spring Boot application starts Tomcat, it will ensure that Tomcat's MBean registration mechanism is activated. Once the MBeans are registered, spring-boot-starter-actuator is able to rediscover and collect these metrics and expose them through the /actuator/metrics endpoint.
Important tips and verification
- Version compatibility: The above solution mainly addresses the problem of missing Tomcat indicators caused by Spring Boot Actuator version upgrade (especially 2.7.0 and later versions). For other versions or different questions, you may want to consult the official Spring Boot documentation or Tomcat's JMX configuration guide.
- Metric verification: After the application is restarted, you can verify that Tomcat metrics have been restored by accessing the /actuator/metrics endpoint. You should see familiar metrics such as tomcat.cache.access, tomcat.global.error, etc. For more precise verification, you can access the metric-specific endpoint, such as /actuator/metrics/tomcat.cache.access.
- Performance considerations: Enabling Tomcat Mbean registration usually does not introduce significant performance overhead, because JMX MBeans are mainly used for monitoring and management, and will only be accessed when requested. But in extremely high-concurrency or resource-constrained environments, performance testing is always recommended to ensure there are no unintended effects.
- Other monitoring: In addition to Tomcat indicators, Actuator also provides a wealth of JVM, system, and application custom indicators. It is recommended to use various indicators in combination to build a comprehensive application monitoring system.
Summarize
When the Spring Boot Actuator upgrade causes Tomcat indicators to be missing, this problem can be effectively solved by simply setting server.tomcat.mbeanregistry.enabled=true in application.properties. This configuration item ensures that Tomcat's MBean registration mechanism is activated, allowing Actuator to re-collect and expose these key runtime performance indicators. In a production environment, complete monitoring data is critical for troubleshooting, performance optimization, and system health assessment, so ensuring that all necessary metrics are available is fundamental to maintaining high availability and high-performance applications.
The above is the detailed content of Solution to Tomcat indicator loss after Spring Boot Actuator upgrade. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

ArtGPT
AI image generator for creative art from text prompts.

Stock Market GPT
AI powered investment research for smarter decisions

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Use the -cp parameter to add the JAR to the classpath, so that the JVM can load its internal classes and resources, such as java-cplibrary.jarcom.example.Main, which supports multiple JARs separated by semicolons or colons, and can also be configured through CLASSPATH environment variables or MANIFEST.MF.

UseFile.createNewFile()tocreateafileonlyifitdoesn’texist,avoidingoverwriting;2.PreferFiles.createFile()fromNIO.2formodern,safefilecreationthatfailsifthefileexists;3.UseFileWriterorPrintWriterwhencreatingandimmediatelywritingcontent,withFileWriterover

JavaSPI is a built-in service discovery mechanism in JDK, and implements interface-oriented dynamic expansion through ServiceLoader. 1. Define the service interface and create a file with the full name of the interface under META-INF/services/, and write the fully qualified name of the implementation class; 2. Use ServiceLoader.load() to load the implementation class, and the JVM will automatically read the configuration and instantiate it; 3. The interface contract should be clarified during design, support priority and conditional loading, and provide default implementation; 4. Application scenarios include multi-payment channel access and plug-in verification; 5. Pay attention to performance, classpath, exception isolation, thread safety and version compatibility; 6. In Java9, provide can be used in combination with module systems.

Use the implements keyword to implement the interface. The class needs to provide specific implementations of all methods in the interface. It supports multiple interfaces and is separated by commas to ensure that the methods are public. The default and static methods after Java 8 do not need to be rewrite.

Javagenericsprovidecompile-timetypesafetyandeliminatecastingbyallowingtypeparametersonclasses,interfaces,andmethods;wildcards(?,?extendsType,?superType)handleunknowntypeswithflexibility.1.UseunboundedwildcardwhentypeisirrelevantandonlyreadingasObject

This article explores in-depth the mechanism of sending multiple HTTP requests on the same TCP Socket, namely, HTTP persistent connection (Keep-Alive). The article clarifies the difference between HTTP/1.x and HTTP/2 protocols, emphasizes the importance of server-side support for persistent connections, and how to correctly handle Connection: close response headers. By analyzing common errors and providing best practices, we aim to help developers build efficient and robust HTTP clients.

This tutorial details how to efficiently process nested ArrayLists containing other ArrayLists in Java and merge all its internal elements into a single array. The article will provide two core solutions through the flatMap operation of the Java 8 Stream API: first flattening into a list and then filling the array, and directly creating a new array to meet the needs of different scenarios.

The answer is to use Thread.currentThread().getStackTrace() to get the call method name, and obtain the someMethod name of the call anotherMethod through index 2. Since index 0 is getStackTrace, 1 is the current method, and 2 is the caller, the example output is "Calledbymethod:someMethod", which can also be implemented by Throwable, but attention should be paid to performance, obfuscation, security and inline impact.
