Monitoring Spring Boot Tomcat Metrics with Actuator and Prometheus

This article explains how to use Spring Boot Actuator to expose Tomcat performance metrics, retrieve health and metric endpoints via HTTP, configure custom endpoints, and optionally log or export the data to Prometheus for continuous monitoring and analysis.

Selected Java Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Monitoring Spring Boot Tomcat Metrics with Actuator and Prometheus

Spring Boot greatly speeds up web service development with its embedded container, but the gateway layer—being the entry point for user requests—often becomes a performance bottleneck that requires careful tuning.

The Spring Boot Actuator module provides built‑in endpoints for monitoring application health, thread usage, and other runtime information.

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

After the application starts, Actuator exposes HTTP endpoints under http://{application}/actuator. The default endpoints include /actuator/info and /actuator/health.

The base path can be changed with the property: management.endpoints.web.base-path=/mypath Example to query health status:

$ curl 'http://localhost:8080/actuator/health' -i -X GET

Typical response:

{
  "status" : "UP"
}

To obtain more detailed health data, enable the property: management.endpoint.health.show-details=always Resulting JSON may include Redis and disk‑space details.

For deeper container metrics, the /actuator/metric endpoint must be exposed:

# Enable metric endpoint
management.endpoints.web.exposure.include=info,health,metric

Calling the metric endpoint lists all available metric names, such as:

"tomcat.threads.config.max"
"tomcat.threads.current"
"tomcat.threads.busy"

Specific values are retrieved by appending the metric name, e.g.:

$ curl 'http://localhost:8080/actuator/metric/tomcat.threads.busy'
{
  "name":"tomcat.threads.busy",
  "measurements":[{"statistic":"VALUE","value":1.0}],
  "availableTags":[{"tag":"name","values":["http-nio-10610"]}]
}

During traffic spikes, these real‑time metrics help pinpoint performance issues. For historical analysis, a service can periodically scrape the metrics; Spring Boot offers a Prometheus exporter for this purpose (see https://www.callicoder.com/spring-boot-actuator-metrics-monitoring-dashboard-prometheus-grafana/).

Alternatively, metrics can be logged at regular intervals using a LoggingMeterRegistry bean:

@Configuration
class MetricsConfig {
    @Bean
    LoggingMeterRegistry loggingMeterRegistry() {
        return new LoggingMeterRegistry();
    }
}

The required LoggingMeterRegistry class is part of micrometer‑core version 1.10+. If using Spring Boot 1.x, add the dependency manually:

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-core</artifactId>
    <version>1.1.3</version>
</dependency>

Log output (default every minute) includes JVM buffers, memory usage, thread states, and Tomcat thread metrics such as:

tomcat.threads.busy{name=http-nio-10610} value=0 threads
tomcat.threads.config.max{name=http-nio-10610} value=200 threads
tomcat.threads.current{name=http-nio-10610} value=10 threads

To change the logging frequency, customize the LoggingRegistryConfig:

return new LoggingMeterRegistry(new LoggingRegistryConfig() {
    @Override
    public Duration step() { return Duration.ofSeconds(10); } // every 10 seconds
    @Override
    public String get(String key) { return null; }
}, Clock.SYSTEM);
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

monitoringMetricsPrometheusSpring BootActuator
Selected Java Interview Questions
Written by

Selected Java Interview Questions

A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.