Problem statement: what is actuator in spring boot?
Actuator provides production ready features of spring boot project that helps to monitor and manage application by invoking different HTTP endpoints exposed by spring boot actuator. such as application
Actuator provides production ready features of spring boot project that helps to monitor and manage application by invoking different HTTP endpoints exposed by spring boot actuator. such as application
- health (active/inactive)
- version details (version of branch, date & time of deployment)
- logger details
- configurations
- bean details
- How do you enable spring boot actuator?
- Need to include maven dependency in existing pom.xml file
- spring-boot-starter-actuator
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
endpoints.metrics.id=springbeans
endpoints.metrics.sensitive=false
endpoints.metrics.enabled=true
- What do you mean by endpoints ?
- Endpoints allow you to monitor & interact with the application.
- Spring boot provides a number of built-in endpoints and it lets you add your own / custom endpoints.
- for example health endpoint provides basic application health information
- each individual endpoints can be enabled or disabled by using id, enabled, sensitive property in application.properties file.
- What are the default endpoints in Spring Boot?
- health - displays application health information.
- beans - displays a list of all spring beans in your application.
- info - displays arbitrary application info.
- loggers - displays & modifies the configuration of loggers in the application.
- threaddump - Performs a thread dump.
- httptrace - displays HTTP trace information (by default, the last 100 HTTP request-response exchanges).
- sessions - Allows retrieval and deletion of user sessions from a Spring Session-backed session store. Not available when using Spring Session’s support for reactive web applications.
- shutdown - Lets the application be gracefully shutdown.
- metrics - displays metrics information of application.
- If your application is a web application (Spring MVC, Spring WebFlux, or Jersey), you can use the following additional endpoints:
- heapdump - Returns a GZip compressed
hprof
heap dump file.
- How do you enable endpoints in spring boot?
- By default, all endpoints except for shutdown are enabled.
- to configure enablement of an endpoints, use its
management.endpoint.<id>.enabled=true
property in application.properties file
- How do you enable shutdown endpoints ?
management.endpoint.shutdown.enabled=true
- What are the default exposing endpoints to the WEB (external world)?
- health - yes
- info - yes
- beans - no
- loggers - no
- threaddump - no
- httptrace - no
- sessions - no
- shutdown - no
- heapdump - no
- metrics - no
- How do you change which endpoints to be exposed to Web or JMX?
- using
include
andexclude
properties
- Default endpoints ID's exposure are:
- management.endpoints.web.exposure.include = health,info
- management.endpoints.jmx.exposure.include = *
- How do you expose all the endpoints over HTTP / web?
*
can be used to select all endpoints properties.- example - management.endpoints.web.exposure.include=*
- How do you expose everything over HTTP / web / external world except
env
andbeans
endpoints?
management.endpoints.web.exposure.include=* management.endpoints.web.exposure.exclude=env,beans
- How do you Configure / Customize existing endpoints in Spring Boot Actuator?
- spring boot actuator allows customize endpoints by using spring properties. simply mention the name of the properties that you want to customize in your application.properties.
- How many ways endpoint can be configure / customize in Spring Boot Actuator?
Three ways or three properties are available:
- id - accessed over HTTP
- enabled - if true then it can be accessed otherwise not
- sensitivity - if true then need the authorization to show crucial information over HTTP
Each endpoint can be customized with properties using the format:
endpoints.[endpoint name].[property to customize]
example:
1 - adding the below properties will customize the /beans endpoints:
endpoints.beans.id=springbeans
endpoints.beans.sensitive=false
endpoints.beans.enabled=true
1 - adding the below properties will customize the /beans endpoints:
endpoints.beans.id=springbeans
endpoints.beans.sensitive=false
endpoints.beans.enabled=true
2 - adding the below properties will customize the /metrics endpoints:
endpoints.metrics.id=springbeans
endpoints.metrics.sensitive=false
endpoints.metrics.enabled=true
No comments:
Post a Comment