无法访问 Spring Boot Actuator“/actuator”端点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35517713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 00:59:38  来源:igfitidea点击:

Unable to access Spring Boot Actuator "/actuator" endpoint

springspring-bootspring-boot-actuator

提问by grkhyd

I am able to access endpoints like http://localhost:8081/health, /status, /env, /metrics, /shutdownbut not/actuatoror /loginfoendpoints.

我能够访问端点,如http://localhost:8081/health, /status, /env, /metrics/shutdown不能访问/actuator/loginfo端点。

Getting below exception.

低于异常。

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

How to acccess http://localhost:8081/actuatorendpoint?

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

回答by Shanu Gupta

As of spring boot version 2.0.1 using below property would work

从 spring boot 版本 2.0.1 开始,使用以下属性可以工作

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

You can use *wildcard to expose all actuator endpoints over the web if security isn't your concern.

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

Also endpoints seems to have moved from previous versions. For ex. if you wish to use beans, you would now have /actuator/beansendpoint.

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

Just to be sure look at startup logs for such endpoints.

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

More on endpoints can be found here

可以在此处找到有关端点的更多信息

回答by BERGUIGA Mohamed Amine

If you type http://localhost:8080/actuator/yo'll get the list of endpoints that has been exposed by default (3 endpoint) so in order to expose all your endpoint what you have to add in your application.properties/ymlfile:

如果您键入,您http://localhost:8080/actuator/将获得默认情况下已公开的端点列表(3 个端点),以便公开您必须在application.properties/yml文件中添加的所有端点:

management.endpoints.web.exposure.include=*

回答by Mohammed Rafeeq

as of springboot 2.0.5.RELEASEthe health check endpoint is http://hostname:portnumber/applicationroot/actuator/health

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

also check if you have added the dependency

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

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

回答by Adelin

I got a pretty descriptive message

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

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.

So I put the property in the applicaiton.properties

所以我把属性放在 applicaiton.properties

management.security.enabled=false 

And it will worked

它会起作用

回答by Kumar Abhishek

Actuator endpoints moved in Spring Boot 2.0.0, so you need to check /application/health.

Actuator 端点在 Spring Boot 2.0.0 中移动,因此您需要检查/application/health.

Gradle:

摇篮:

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

Edit the build.gradle file and change the Boot version to 1.5.4.RELEASE. Run the app.

编辑 build.gradle 文件并将引导版本更改为 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"}

回答by xuesheng

It looks like you mapped your Actuatorendpoints to the base path /. Check if you have the following line in your configuration:

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

management.endpoints.web.base-path=/

So, if you omit this line, then you will access all endpoints under actuatorpath, e.g.:

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

http://localhost:8081/actuator/health

and the actuator itself will become accessible here:

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

http://localhost:8081/actuator

回答by Elan Hershcovitz

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

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

change the application.properties fle for this would allow you use http://localhost:8080/beans(or /health , /env )

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

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

回答by Qusai Dahboor

health check endpoint as of Spring Boot 2.1.5.RELEASE

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

http://localhost:8080/actuator/health

http://localhost:8080/actuator/health

check if you have added the dependency

检查您是否添加了依赖项

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

check if you have added the application.properties

检查您是否添加了application.properties

management.endpoints.web.exposure.include = *

management.endpoints.web.exposure.include = *

回答by Zgpeace

Base on @Vinod's answer, I add application.yml content.
For spring boot 2.1.0 please add below property value in application.yml file.

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

management:
  endpoints:
    web:
      exposure:
        include: '*'
  endpoint:
    health:
      show-details: always
    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

More endpoint, see the link:
Part V. Spring Boot Actuator: Production-ready features

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

回答by zappcity

Make sure that those 'sensitive' endpoints are enabled. This docdescribes how to enable all sensitive endpoints or individual ones. It sounds like you have certain sensitive endpoints enabled (like shutdown) but not others (like actuator).

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

To enable all sensitive endpoints:

启用所有敏感端点:

endpoints.sensitive=true

To enable actuator and logfile individually:

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

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