亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
Tomcat indicator missing phenomenon
Mbean registration mechanism and Actuator
core solution
Configuration example
Important tips and verification
Summarize
Home Java javaTutorial Solution to Tomcat indicator loss after Spring Boot Actuator upgrade

Solution to Tomcat indicator loss after Spring Boot Actuator upgrade

Oct 12, 2025 am 07:54 AM

Solution to Tomcat indicator loss after Spring Boot Actuator upgrade

This tutorial aims to solve the problem of some Tomcat indicators (such as tomcat.cache.access, tomcat.global.error) disappearing in MetricsEndpoint after the Spring Boot Actuator is upgraded. The core solution is to configure server.tomcat.mbeanregistry.enabled=true in application.properties to enable Tomcat's MBean registration mechanism to resume monitoring of these key runtime indicators.

Tomcat 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

  1. 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.
  2. 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.
  3. 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.
  4. 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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

How to add a JAR file to the classpath in Java? How to add a JAR file to the classpath in Java? Sep 21, 2025 am 05:09 AM

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.

How to create a file in Java How to create a file in Java Sep 21, 2025 am 03:54 AM

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

Building Extensible Applications with the Java Service Provider Interface (SPI) Building Extensible Applications with the Java Service Provider Interface (SPI) Sep 21, 2025 am 03:50 AM

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.

How to implement an interface in Java? How to implement an interface in Java? Sep 18, 2025 am 05:31 AM

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.

Understanding Java Generics and Wildcards Understanding Java Generics and Wildcards Sep 20, 2025 am 01:58 AM

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

A deep understanding of HTTP persistent connections: policies and practices for sending multiple requests on the same socket A deep understanding of HTTP persistent connections: policies and practices for sending multiple requests on the same socket Sep 21, 2025 pm 01:51 PM

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.

Java Tutorial: How to Flatten a Nested ArrayList and Fill its Elements into an Array Java Tutorial: How to Flatten a Nested ArrayList and Fill its Elements into an Array Sep 18, 2025 am 07:24 AM

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.

How to get the calling method's name in Java? How to get the calling method's name in Java? Sep 24, 2025 am 06:41 AM

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.

See all articles