【问题标题】:Unable to access Spring Boot Actuator "/actuator" endpoint无法访问 Spring Boot Actuator“/actuator”端点
【发布时间】:2016-06-01 18:12:24
【问题描述】:

我可以访问http://localhost:8081/health/status/env/metrics/shutdown 等端点,但 不能/actuator/loginfo 端点。

遇到异常。

{"timestamp":1455929182552,"status":404,"error":"Not Found","message":"No message available","path":"/actuator"}

如何访问http://localhost:8081/actuator端点?

【问题讨论】:

  • 你的依赖项中有spring-boot-starter-actuator吗?
  • 是的,我的依赖项中有它。
  • 解决了吗?我也面临同样的问题。使用的spring boot版本-1.3.2
  • 对我来说这很奇怪,当我运行打包的 jar 时我得到 404 :(

标签: spring spring-boot spring-boot-actuator


【解决方案1】:

从 Spring Boot 版本 2.0.1 开始,使用以下属性将起作用

management.endpoints.web.exposure.include=<comma separated endpoints you wish to expose>

如果您不关心安全性,您可以使用* 通配符通过网络公开所有执行器端点。

端点似乎也从以前的版本中移动了。例如。如果您想使用 bean,您现在将拥有 /actuator/beans 端点。

只是为了确保查看此类端点的启动日志。

有关端点的更多信息可以找到here

【讨论】:

  • 确保包含依赖 spring-boot-actuator-autoconfigure
  • 当使用 application.yml 而不是 application.properties 我无法让 * 工作,所以我不得不列出各种端点(可从链接获得)。谢谢。管理:端点:web:暴露:包括:bean、env、health、info
【解决方案2】:

如果您输入http://localhost:8080/actuator/,您将获得默认公开的端点列表(3 个端点),因此为了公开您的所有端点,您必须在application.properties/yml 文件中添加:

management.endpoints.web.exposure.include=*

【讨论】:

    【解决方案3】:

    看起来您已将 Actuator 端点映射到基本路径 /。检查您的配置中是否有以下行:

    management.endpoints.web.base-path=/
    

    所以,如果你省略这一行,那么你将访问actuator路径下的所有端点,例如:

    http://localhost:8081/actuator/health
    

    并且执行器本身将可以在此处访问:

    http://localhost:8081/actuator
    

    【讨论】:

      【解决方案4】:

      截至springboot 2.0.5.RELEASE,健康检查端点为http://hostname:portnumber/applicationroot/actuator/health

      还要检查你是否添加了依赖项

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

      【讨论】:

        【解决方案5】:

        我遇到了同样的问题,花了几个小时后,可以解决。 首先我们需要将下面的属性设置为 *

        management.endpoints.web.exposure.include=*
        management.endpoints.enabled-by-default=false
        

        我们需要提供以下属性端口,而不是 URL 中的 server.port。

        management.server.port=9000
        

        示例:

        http://localhost:9000/actuator/loggers/{package}
        http://localhost:9000/actuator/health
        

        这是在带有 spring boot 2.1.13 的微服务中尝试的,具有以下属性并且工作正常。

        management.endpoints.web.exposure.include=*
        management.endpoint.loggers.enabled=true
        management.endpoint.restart.enabled=true
        management.endpoint.refresh.enabled=true
        management.endpoint.health.enabled=true
        management.security.enabled=false
        management.health.db.enabled=true
        management.health.diskspace.enabled=true
        

        【讨论】:

          【解决方案6】:

          在 Spring Boot 2.0.0 中移动了执行器端点,因此您需要检查 /application/health

          分级:

          compile('org.springframework.boot:spring-boot-starter-actuator')
          springBootVersion = '2.0.0.M3'*
          

          编辑 build.gradle 文件并将 Boot 版本更改为 1.5.4.RELEASE。运行应用程序。

          curl -i localhost:8080/health
          
          HTTP/1.1 200
          X-Application-Context: application
          Content-Type: application/vnd.spring-boot.actuator.v1+json;charset=UTF-8
          Transfer-Encoding: chunked
          Date: Wed, 14 Jun 2017 20:45:51 GMT
          
          {"status":"UP"}
          

          【讨论】:

          • 是的,我可以到达 /application 端点,但这是唯一的一个。无法到达 /heath 等。
          • Acutator 端点再次被移动,前缀现在是 /actuator 而不是 /application
          【解决方案7】:

          我收到了一条描述性很强的消息

          2017-11-09 23:27:14.572  INFO 30483 --- [nio-8080-exec-2] s.b.a.e.m.MvcEndpointSecurityInterceptor : Full authentication is required to access actuator endpoints. Consider adding Spring Security or set 'management.security.enabled' to false.
          

          所以我把属性放在 applicaiton.properties 中

          management.security.enabled=false 
          

          它会起作用的。

          更新management.security.enabled 现在在 Spring Boot 2 中已弃用,谢谢 @Abdelghani Roussi

          【讨论】:

          • management.security.enabled 现在在 Spring Boot 2 中已弃用
          【解决方案8】:

          检查https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#base-path

          为此更改 application.properties 文件将允许您使用 http://localhost:8080/beans (或 /health , /env )

          server.port=8080
          management.endpoints.web.base-path=/
          management.endpoints.web.exposure.include=*
          

          【讨论】:

            【解决方案9】:

            基于@Vinod 的回答,我添加了 application.yml 内容。
            对于 spring boot 2.1.0,请在 application.yml 文件中添加以下属性值。

            management:
              endpoints:
                web:
                  exposure:
                    include: '*'
              endpoint:
                health:
                  show-details: always
                beans:
                  enabled: true
            

            从运行应用程序的本地系统[浏览器或邮递员]访问以下网址。

            http://localhost:8080/actuator/metrics
            http://localhost:8080/actuator/health
            http://localhost:8080/actuator/beans
            

            更多端点,见链接:
            Part V. Spring Boot Actuator: Production-ready features

            【讨论】:

              【解决方案10】:

              确保启用那些“敏感”端点。 This doc 描述了如何启用所有敏感端点或单个端点。听起来您启用了某些敏感端点(例如关闭),但没有启用其他端点(例如执行器)。

              启用所有敏感端点:

              endpoints.sensitive=true
              

              单独启用执行器和日志文件:

              endpoints.actuator.enabled=true
              endpoints.logfile.enabled=true
              

              【讨论】:

              • 我的属性文件中已经有它们endpoints.beans.id=springbeans endpoints.beans.sensitive=true endpoints.shutdown.enabled=true endpoints.enabled=true endpoints.info.enabled=true endpoints.metrics.id=metrics endpoints.metrics.sensitive=true endpoints.metrics.enabled=true endpoints.actuator.enabled=true endpoints.logfile.enabled=true management.port=8081 management.security.enabled=true management.security.role=SUPERUSER security.user.name=admin security.user.password=secret123 security.require_ssl=false security.basic.enabled=true
              • 这是我正在尝试处理的示例link
              【解决方案11】:
              For spring boot 2.x.x please add below property value in application.property file.
              
              management.endpoint.health.show-details=ALWAYS
              management.endpoints.web.exposure.include=*
              management.endpoint.beans.enabled=true
              
              Access below url from your local system[either browser or postman] from where you are running a application.
              
              http://localhost:8080/actuator/metrics
              http://localhost:8080/actuator/health
              http://localhost:8080/actuator/beans
              

              【讨论】:

                【解决方案12】:

                Spring Boot 的健康检查端点2.1.5.RELEASE

                http://localhost:8080/actuator/health

                检查是否添加了依赖

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

                检查您是否添加了 application.properties

                management.endpoints.web.exposure.include = *

                【讨论】:

                  【解决方案13】:

                  弹簧靴1.5.6

                  执行器 为其他端点提供基于超媒体的“发现页面”。要求 Spring HATEOAS 在类路径上。

                  请看:https://docs.spring.io/spring-boot/docs/1.5.6.RELEASE/reference/html/production-ready-endpoints.html

                  【讨论】:

                    【解决方案14】:

                    我总是更喜欢使用应用程序的基本 URL 提供上下文路径。现在要配置执行器,我们应该在 pom.xml 中包含以下依赖项

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

                    让它使用 Spring boot 版本所承载的默认版本。 将以下属性放入您的 application.properties

                    server.servlet.contextPath=/<app-name>
                    server.port=8080
                    
                    management.endpoint.metrics.enabled=true
                    management.endpoints.web.exposure.include=*
                    management.endpoint.prometheus.enabled=true
                    management.metrics.export.prometheus.enabled=true
                    management.security.enabled=false
                    management.health.mongo.enabled=false
                    management.health.redis.enabled=false
                    management.health.rabbit.enabled=false
                    management.endpoint.health.show-details=always
                    
                    #/metrics endpoint configuration
                    endpoints.metrics.id=metrics
                    endpoints.metrics.sensitive=false
                    endpoints.metrics.enabled=true
                    
                    #/health endpoint configuration (Comment when you are using customized health check)
                    endpoints.health.id=health
                    endpoints.health.sensitive=false
                    endpoints.health.enabled=true
                    
                    info.app.name=@project.name@
                    info.app.description=@project.description@
                    info.app.version=@project.version@
                    info.app.encoding=@project.build.sourceEncoding@
                    info.app.java.version=@java.version@
                    

                    在启动服务器后进行上述配置后,您可以轻松检查以下 http 调用的指标-

                     # curl http://localhost:8080/myapp/actuator/metrics
                     {
                      "names": ["jvm.buffer.memory.used", "jvm.gc.memory.allocated", 
                      "jvm.memory.committed", "jvm.memory.used", "http.server.requests", 
                      "jvm.gc.max.data.size", "logback.events", "system.cpu.count", 
                      "jvm.memory.max", "jvm.buffer.total.capacity", "jvm.buffer.count", 
                      "process.files.max", "jvm.threads.daemon", "process.start.time", 
                      "jvm.gc.live.data.size", "process.files.open", "process.cpu.usage", 
                      "process.uptime", "system.load.average.1m", "jvm.gc.pause", 
                      "system.cpu.usage", "jvm.threads.live", "jvm.classes.loaded", 
                      "jvm.classes.unloaded", "jvm.threads.peak", "jvm.gc.memory.promoted"]
                    }
                    

                    详情可以看我的博客here

                    【讨论】:

                      【解决方案15】:

                      首先你应该确保你的 pom.xml 中有以下依赖项

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

                      那么你的application.yml中应该有如下配置

                       management:
                            endpoint:
                              health:
                                enabled: true
                                show-details: always
                            endpoints:
                              web:
                                exposure:
                                  include: '*'
                              jmx:
                                exposure:
                                  include: '*'
                      

                      您可以在 application.yml 中使用以下配置自定义 info enpoit 中的信息

                      info:
                          app:
                              name: @project.name@
                              description: @project.description@
                              version: @project.version@
                              encoding: @project.build.sourceEncoding@
                              java:
                                  version: @java.version@
                      

                      之后,你可以去url localhost:8080看到端点列表如下:

                      希望这个答案可以帮助别人

                      【讨论】:

                        【解决方案16】:

                        http://localhost:8080/actuator/ 出现显示问题,并通过添加 hal-explorer 依赖项得到解决。请确保您的 pom.xml 中有以下 2 个依赖项,以便为执行器显示正确的内容。

                                <dependency>
                                    <groupId>org.springframework.data</groupId>
                                    <artifactId>spring-data-rest-hal-explorer</artifactId>
                                </dependency>
                                <dependency>
                                    <groupId>org.springframework.boot</groupId>
                                    <artifactId>spring-boot-starter-actuator</artifactId>
                                </dependency>
                        

                        还要检查 application.properties 中的以下属性

                        management.endpoints.web.exposure.include=*
                        #management.endpoints.enabled-by-default=false
                        #management.endpoints.web.base-path=/
                        

                        【讨论】:

                          【解决方案17】:

                          我遇到了同样的问题。

                          1. 在控制台中检查诸如“无效 LOC 标头(错误签名)”之类的错误。 执行“mvn spring-boot:run”以获取日志。
                            我的 sprint-boot-starter-actuator 已损坏!

                          2. 在我的例子中,执行器 url 是

                          希望对你有帮助

                          【讨论】:

                            【解决方案18】:

                            根据docs,我猜没有名为 /loginfo 的端点

                            对于 /actuator 端点,请参阅 answer 上类似的 question

                            【讨论】:

                              【解决方案19】:

                              这里是 application.yml 文件,用于将基本路径更改为 / 并禁用 /info。

                              management:
                                endpoints:
                                  web:
                                    base-path: /
                                endpoint:
                                  #Disable /info
                                  info:
                                    enabled: false
                                  health:
                                    show-details: always
                                health:
                                    defaults:
                                      enabled: false
                              

                              【讨论】:

                                【解决方案20】:

                                你可以试试base-path这样的配置

                                management:
                                  endpoints:
                                    web:
                                      base-path: /actuator
                                      exposure:
                                        include: info, health
                                

                                【讨论】:

                                  猜你喜欢
                                  • 2020-09-15
                                  • 2019-01-08
                                  • 1970-01-01
                                  • 2016-03-27
                                  • 1970-01-01
                                  • 1970-01-01
                                  • 2016-09-07
                                  • 2021-04-24
                                  • 2020-06-01
                                  相关资源
                                  最近更新 更多