Friday, August 11, 2017

Spring Boot - Actuator - Health Check

Spring Boot provides actuator to monitor and manage our application. Actuator is a tool which has HTTP endpoints. when application is pushed to production, you can choose to manage and monitor your application using HTTP endpoints.

To get production-ready features, we should use spring-boot-actuator module. We can enable this feature by adding it to the pom.xml file.Actuator such as application health, bean details, version details, configurations, logger details, etc.

Spring Boot includes a number of built-in endpoints, and you can also add your own or even configure existing endpoints to be exposed on any custom endpoints of your choice. It is obvious that all the endpoints cannot be exposed publicly, considering that there are many sensitive endpoints like beans, env, etc. Hence, Spring Boot also sets sensitive defaults to true for many endpoints that require a username/password when they are accessed over HTTP (or simply disabled if web security is not enabled). Health and info are not sensitive by default.

 
     
        org.springframework.boot  
        spring-boot-starter-actuator  
   
 
 


http://localhost:8081/health

{"description":"Spring Cloud Eureka Discovery Client","status":"UP"}

if we specify context name then

http://localhost:8081/context/health

$ curl localhost:8080/health
{"status":"UP"}
You’re "UP", so that’s good.

Endpoints

Actuator endpoints allow us to monitor and interact with our Spring Boot application. Spring Boot includes number of built-in endpoints and we can also add custom.

The following table contains the available endpoints.

Id Description Sensitive default
actuator It provides a hypermedia-based "discovery page" for the other endpoints. It requires Spring HATEOAS to be on the classpath. True
auditevents It exposes audit events information for the current application. True
autoconfig It is used to display an auto-configuration report showing all auto-configuration candidates and the reason why they 'were' or 'were not' applied. True
beans It is used to display a complete list of all the Spring beans in your application. True
configprops It is used to display a collated list of all @ConfigurationProperties. True
dump It is used to perform a thread dump. True
env It is used to expose properties from Spring's ConfigurableEnvironment. True
flyway It is used to show any Flyway database migrations that have been applied. True
health It is used to show application health information. False
info It is used to display arbitrary application info. False
loggers It is used to show and modify the configuration of loggers in the application. True
liquibase It is used to show any Liquibase database migrations that have been applied. True
Metrics It is used to show metrics information for the current application. True
mappings It is used to display a collated list of all @RequestMapping paths. True
shutdown It is used to allow the application to be gracefully shutdown. True
trace It is used to display trace information. True
For Spring MVC, the following additional endpoints can also be used.

Id Description Sensitive default
docs It is used to display documentation, including example requests and responses for the Actuator's endpoints. False
heapdump It is used to return a GZip compressed hprof heap dump file. True
jolokia It is used to expose JMX beans over HTTP (when Jolokia is on the classpath). True
logfile It is used to return the contents of the logfile. True

endpoints.sensitive=true
endpoints.info.sensitive=false
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


No comments:

Post a Comment

உப்பு மாங்காய்

சுருக்குப்பை கிழவி. சுருக்கங்கள் சூழ் கிழவி. பார்க்கும் போதெல்லாம் கூடையுடனே குடியிருப்பாள். கூடை நிறைய குட்டி குட்டி மாங்காய்கள். வெட்டிக்க...