- Out-of-the-box production-ready features, like monitoring, metrics, health checks, audit events and more
- Provided with spring-boot-starter-actuator dependency
- Access through HTTP endpoints, like /actuator/health
What are the two protocols you can use to access actuator endpoints?
- HTTP
- JMX
What are the actuator endpoints that are provided out of the box?
- /actuator: provides a hypermedia-based discovery page for all the other endpoints (requires spring-boot-starter-hateoas)
- /health: application health checks
- /configprops: lists all the configuration properties that are defined by the @ConfigurationProperties beans
- /beans: lists all Spring beans
- /env: exposes all the properties from the Spring Environment abstraction. Displays application properties, active profiles and system environment variables
- /httptrace: Shows most recent HTTP requests/responses
- /info: general application info
- /metrics: memory, performance, processor, garbage collection, and HTTP requests
- /loggers: view logs (also change without restarting app)
What is info endpoint for? How do you supply data?
- Actuator's info endpoint is used to project user-customized application data, like application name, version, description, java runtime and more
- The endpoint is exposed through HTTP (/actuator/info) or JMX (org.springframework.boot/Endpoint/Info)
- To supply data, in application.properties define info.app.name/description/version or info.java-vendor. Alternatively, create a Component implementing InfoContributor
How do you change logging level of a package using loggers endpoint?
- Execute a POST in /actuator/loggers endpoint and specific package, like:
- curl -i -X POST -H 'Content-Type: application/json' -d '{"configuredLevel": "INFO"}' http://localhost:8080/actuator/loggers/com.code.in.packets.package1.logging
- Also, make to enable loggers endpoint:
- management.endpoints.web.exposure.include=loggers
How do you access an endpoint using a tag?
- Using syntax: /actuator/metrics/<metric>?tag=<key>:<value>
- Example listing all GET requests that resulted in a server error:
- /actuator/metrics/http.server.requests?tag=outcome:SERVER_ERROR&tag=method:GET
What is metrics for?
- Actuator metrics are implemented by Micrometer
- Provide information about: memory usage, CPU usage, threads, garbage collection, application uptime, heap size, site-visited count and more
- Need to explicitly enable in properties: management.endpoints.web.exposure.include=metrics
How do you create a custom metric?
- Inject a MeterRegistry dependency in a Component
- Use MeterRegistry's methods, like timer, counter, gaugeNewCollection and more to display desired info, like:
- meterRegistry.gaugeCollectionSize("employeesList.size", Tags.empty(), this.employeesList)
- meterRegistry.counter("<metric-name>", "<key>", <value>).increment();
What is Health Indicator?
- HealthIndicator API and its endpoint "/actuator/health" is used to produce information about application status and overall health
- External systems can consume it in order to decide any time if we have a fault tolerant and durable application
- The endpoint provides all Health Indicators that are set programmatically as components that implement HealthIndicator and override health method
- Health Indicators are provided/autoconfigured by Spring Actuator, when relevant dependencies are found
What are the Health Indicators that are provided out of the box?
ApplicationHealthIndicator, should always be UP
DiskSpaceHealthIndicator, DOWN if low disk space is available
DataSourceHealthIndicator, UP if connection successful, otherwise DOWN
.
JmsHealthIndicator, UP if connection with message broker successful, otherwise DOWN
.
Similar for Mail, Redis, Neo4J, Solr and more
What is the Health Indicator status?
What are the Health Indicator statuses that are provided out of the box?
- All Health Indicators return a health status if triggered (from overwritten health method), that are aggregated and displayed in /health endpoint. These statuses are:
- UP (200)
- DOWN (503)
- UNKNOWN (200)
- OUT_OF_SERVICE (503)
How do you change the Health Indicator status severity order?
- Configure "management.health.status.order" property, like:
- management.health.status.order=DOWN, OUT_OF_SERVICE, UNKNOWN, UP
Why do you want to leverage 3rd-party external monitoring system?
- Necessity: Decoupling code from system monitoring utilities, and having an extra system for alert, data/visitor visualizations, and more
- Easy with Spring: Spring Actuator uses Micrometer that is a facade for multiple external monitoring systems, like Elastic, Atlas, KairosDB and more. We only need to import dependency with groupId = io.micrometer, and artifactId = micrometer-registry-${external-monitoring-system}
-----------------------------------------------------------------------------------------------------
Questions from EDU-1202 exam (2021)
Actuator JMX endpoints can also be turned on for HTTP
- True
Actuator metrics can be leveraged by third-party providers for purposes of visualization
- True
Providers (Prometheus, Grafana, etc) can be adjusted easily by declaring dependency in pom.xml
- True
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
What may be missing, or could get better?