Actuator is a very helpful library which allow you to monitor the application.
Mainly used to expose different types of information about the running application – health, metrics, info, dump, env etc.
To start using the existing actuators in Boot – we’ll just need to add the spring-boot-actuator dependency to the pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Endpoints - The boot comes with many built-in endpoints and, like with pretty much anything in Spring – you can also roll your own.
Most endpoints are sensitive – meaning they’re not fully public – while a handful is not: /health and /info.
Here are some of the most common endpoints Boot provides out of the box:
/health – Shows application health information (a simple ‘status’ when accessed over an unauthenticated connection or full message details when authenticated). It is not sensitive by default.
/info – Displays arbitrary application info. Not sensitive by default.
/metrics – Shows ‘metrics’ information for the current application. It is also sensitive by default.
/env – Exposes properties from Spring’s Configurable Environment.
/beans – Displays a complete list of all the Spring beans in your application.
/configprops – Displays a collated list of all @ConfigurationProperties.
/dump – Performs a thread dump.
/logfile – Returns the contents of the logfile (if logging.file or logging.path properties have been set). Only available via MVC. Supports the use of the HTTP Range header to retrieve part of the log file’s content.
/metrics – Shows ‘metrics’ information for the current application.
/mappings – Displays a collated list of all @RequestMapping paths.
/trace – Displays trace information (by default the last few HTTP requests).
Customizing Existing Endpoints -
You can customize actuator to display or restrict information that should/shouldn’t be available.
Each endpoint can be customized with properties using the following format: endpoints.[endpoint name].[property to customize]
Three properties are available:
id – by which this endpoint will be accessed over HTTP
enabled – if true then it can be accessed otherwise not
sensitive – if true then need the authorization to show crucial information over HTTP
For example, add the following properties will customize the /beans endpoint:
endpoints.beans.id=springbeans
endpoints.beans.sensitive=false
endpoints.beans.enabled=true
/health Endpoint
The /health endpoint is used to check the health/status of the running application. It’s usually used by basic monitoring software to alert you if the production goes down.
By default only health information is shown to unauthorized access over HTTP:
{
"status" : "UP"
}
This health information is collected from all the beans implementing HealthIndicator interface configured in your application context.
Some information returned by HealthIndicator is sensitive in nature – but you can configure endpoints.health.sensitive=false to expose the other information like disk space, data source etc.
A Custom HealthIndicator
Mainly used to expose different types of information about the running application – health, metrics, info, dump, env etc.
To start using the existing actuators in Boot – we’ll just need to add the spring-boot-actuator dependency to the pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Endpoints - The boot comes with many built-in endpoints and, like with pretty much anything in Spring – you can also roll your own.
Most endpoints are sensitive – meaning they’re not fully public – while a handful is not: /health and /info.
Here are some of the most common endpoints Boot provides out of the box:
/health – Shows application health information (a simple ‘status’ when accessed over an unauthenticated connection or full message details when authenticated). It is not sensitive by default.
/info – Displays arbitrary application info. Not sensitive by default.
/metrics – Shows ‘metrics’ information for the current application. It is also sensitive by default.
/env – Exposes properties from Spring’s Configurable Environment.
/beans – Displays a complete list of all the Spring beans in your application.
/configprops – Displays a collated list of all @ConfigurationProperties.
/dump – Performs a thread dump.
/logfile – Returns the contents of the logfile (if logging.file or logging.path properties have been set). Only available via MVC. Supports the use of the HTTP Range header to retrieve part of the log file’s content.
/metrics – Shows ‘metrics’ information for the current application.
/mappings – Displays a collated list of all @RequestMapping paths.
/trace – Displays trace information (by default the last few HTTP requests).
Customizing Existing Endpoints -
You can customize actuator to display or restrict information that should/shouldn’t be available.
Each endpoint can be customized with properties using the following format: endpoints.[endpoint name].[property to customize]
Three properties are available:
id – by which this endpoint will be accessed over HTTP
enabled – if true then it can be accessed otherwise not
sensitive – if true then need the authorization to show crucial information over HTTP
For example, add the following properties will customize the /beans endpoint:
endpoints.beans.id=springbeans
endpoints.beans.sensitive=false
endpoints.beans.enabled=true
/health Endpoint
The /health endpoint is used to check the health/status of the running application. It’s usually used by basic monitoring software to alert you if the production goes down.
By default only health information is shown to unauthorized access over HTTP:
{
"status" : "UP"
}
This health information is collected from all the beans implementing HealthIndicator interface configured in your application context.
Some information returned by HealthIndicator is sensitive in nature – but you can configure endpoints.health.sensitive=false to expose the other information like disk space, data source etc.
A Custom HealthIndicator
No comments:
Post a Comment