You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot 2.0.0中/actuator/prometheus端点无法暴露求助

Troubleshooting /actuator/prometheus Not Showing Up in Spring Boot 2.0.0

Hey there, let's work through why your /actuator/prometheus endpoint isn't accessible even with management.endpoints.web.exposure.include=* configured. This is a common gotcha in Spring Boot 2.0.x, so here are the key checks to fix it:

  • First, confirm you have the required dependency
    Spring Boot 2.0.0 doesn't include the Prometheus registry out of the box. The /actuator/prometheus endpoint only becomes available when you add the micrometer-registry-prometheus dependency to your build. Make sure it's present:

    For Maven:

    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-prometheus</artifactId>
        <version>1.0.6</version> <!-- Matches Spring Boot 2.0.0's compatible Micrometer version -->
    </dependency>
    

    For Gradle:

    implementation 'io.micrometer:micrometer-registry-prometheus:1.0.6'
    
  • Check your actuator base path
    If you've modified management.endpoints.web.base-path (e.g., set it to /manage), your Prometheus endpoint will be at {base-path}/prometheus instead of /actuator/prometheus. Double-check this configuration property to ensure you're hitting the right URL.

  • Verify security settings aren't blocking the endpoint
    If you're using Spring Security, it might be restricting access to actuator endpoints. Add a rule to allow unauthenticated access to /actuator/prometheus in your security configuration:

    @Configuration
    public class SecurityConfig extends WebSecurityConfigurerAdapter {
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http.authorizeRequests()
                .antMatchers("/actuator/prometheus").permitAll()
                .anyRequest().authenticated();
        }
    }
    

    Even if you don't have explicit Spring Security config, Spring Boot 2.0.0 enables basic security for actuators by default. You can disable this temporarily (for testing) with:

    management.security.enabled=false
    
  • Check startup logs for clues
    Fire up your app and search the logs for "prometheus". If you don't see any lines indicating the endpoint is being registered, that's a strong sign the dependency is missing or misconfigured.

Start with adding the micrometer dependency—it's the most frequent fix for this issue in Spring Boot 2.0.0. If that doesn't work, move through the other checks one by one.

内容的提问来源于stack exchange,提问作者Teruyuki Takazawa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:02:00