Actuator - apinazo/booter GitHub Wiki
booter uses Spring Boot Actuator.
# Actuator.
# https://docs.spring.io/spring-boot/docs/current/actuator-api//html/#overview
# IMP: If this configuration is in the bootstrap file it will be ignored.
# The list of all enabled endpoints will show in the app log when it starts.
management:
endpoints:
web:
base-path: /actuator # URL prefix to all endpoints. "/actuator" by default.
enabled-by-default: true # By default is true but in order to work they must be both enabled and exposed.
exposure:
include: "*" # Expose all endpoints. By default only health and info are exposed.
# exclude: shutdown, beans # Don't expose this endpoints.
# It's possible to manage all endpoints one by one.
endpoint:
demo:
enabled: true # Enables custom endpoint /actuator/demo.
health:
show-details: always # Values: always, never, when-authorized - by Spring Security.
metrics:
web:
server:
# Enable global measurement of all in the app requests. Alternatively this could be set to false
# and then each individual @Controller to measure can be annotated with @Timed.
# Statistics will be available at the URI:
# /actuator/metrics/http.server.requests?tag=uri:<URL encoded endpoint URI>
# Example for /people/{id}:
# http://localhost:8001/actuator/metrics/http.server.requests?tag=uri:%2Fpersons%2F%7Bid%7D
auto-time-requests: true
A very simple custom endpoint. The class is declared as such with the annotations @Endpoint.
@Endpoint(id = "demo") // Declare this bean as an endpoint with the URL /<base-path>/demo.
@ConditionalOnProperty(value = "management.endpoint.demo.enabled") // Enable bean if set to true.
@Component
public class DemoEndpoint {
...
}
A custom endpoint must implement the following methods:
// Returns all keys.
// Example request: curl -i -X GET http://localhost:8001/actuator/demo
@ReadOperation
public Map<String, String> doRead() { ... }
// Returns value for a given key.
// Example request: curl -i -X GET http://localhost:8001/actuator/demo/key1
@ReadOperation
public String doReadKey(@Selector String arg0) { ... }
// Set a new value for a given key.
// Example request: curl -i -X POST -H 'Content-Type: application/json' -d '{"newValue" : "value4"}' http://localhost:8001/actuator/demo/key1
@WriteOperation
public String doWrite(@Selector String arg0, @Nullable String newValue) { ... }
// Removes a key.
// Example request: curl -i -X DELETE http://localhost:8001/actuator/demo/key1
@DeleteOperation
public String doDelete(@Selector String arg0) { ... }
This a customization of an existing endpoint so it has to be attached to it. This done by implementing HealthIndicator.
@Component
public class CustomHealthIndicator implements HealthIndicator { ... }
And then it has to implement the health method:
@Override
public Health health() { ... }