Unable to access Spring Boot Actuator “/actuator”

2020-05-15 14:51发布

问题:

I am able to access endpoints like http://localhost:8081/health, /status, /env, /metrics, /shutdown but not /actuator or /loginfo endpoints.

Getting below exception.

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

How to acccess http://localhost:8081/actuator endpoint?

回答1:

As of spring boot version 2.0.1 using below property would work

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/beans endpoint.

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

More on endpoints can be found here



回答2:

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/yml file:

management.endpoints.web.exposure.include=*


回答3:

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

management.security.enabled=false 

And it will worked



回答4:

as of springboot 2.0.5.RELEASE the health check endpoint is 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>


回答5:

Actuator endpoints moved in Spring Boot 2.0.0, so you need to check /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.

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"}


回答6:

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

management.endpoints.web.base-path=/

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

http://localhost:8081/actuator/health

and the actuator itself will become accessible here:

http://localhost:8081/actuator


回答7:

check 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 )

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


回答8:

Make sure that those 'sensitive' endpoints are enabled. This doc describes 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


回答9:

health check endpoint as of Spring Boot 2.1.5.RELEASE

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

management.endpoints.web.exposure.include = *



回答10:

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.

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



回答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:

I had the same issue.

  1. Check in your console for errors like "invalid LOC header (bad signature)". Do 'mvn spring-boot:run' to get logs.
    My sprint-boot-starter-actuator was corrupted !

  2. In my case the actuators url are

    • http://localhost:8080/actuators/metrics
    • http://localhost:8080/actuators/autoconfig
    • etc.

Hope it helps



回答13:

I guess there is no endpoint named /loginfo according to the docs

for /actuator endpoint, please see answer on the similar question



回答14:

spring boot 1.5.6

actuator Provides a hypermedia-based “discovery page” for the other endpoints. Requires Spring HATEOAS to be on the classpath.

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



回答15:

Here is application.yml file to change base path to / & disable /info.

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


回答16:

I always prefer to provide context path with the base URL of application. Now to configure actuator we should include below dependency into our pom.xml

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

let it use the default version which is being beared by Spring boot version. Put below properties into your 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@

After above configuration once you start your server , you can easily check the metrics as below http calls-

 # 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"]
}

For details you can watch my blog here