I have two services running in Kubernetes, and I need to configure:
1. A health check (using httpGet)
2. Prometheus metrics (via /actuator/prometheus)
My services use either:
• .springframework.cloud:spring-cloud-stream
• .springframework.grpc:spring-grpc-spring-boot-starter
I do not use spring-boot-starter-web and would prefer not to add it just for health checks and metrics.
How can I expose actuator endpoints (/actuator/health, /actuator/prometheus) without adding spring-boot-starter-web? Are there alternative ways to achieve this in a lightweight manner?
Thanks in advance! Spring Boot 3.4.3
I have two services running in Kubernetes, and I need to configure:
1. A health check (using httpGet)
2. Prometheus metrics (via /actuator/prometheus)
My services use either:
• .springframework.cloud:spring-cloud-stream
• .springframework.grpc:spring-grpc-spring-boot-starter
I do not use spring-boot-starter-web and would prefer not to add it just for health checks and metrics.
How can I expose actuator endpoints (/actuator/health, /actuator/prometheus) without adding spring-boot-starter-web? Are there alternative ways to achieve this in a lightweight manner?
Thanks in advance! Spring Boot 3.4.3
Why not use spring-boot-starter-actuator
dependency? That will give you the option of exposing plenty of endpoints.
As for prometheus
, you will have to use io.micrometer:micrometer-registry-prometheus
dependency in addition to enable /actuator/prometheus
. It is plug-and-play so it will start exposing your JVM metrics.
The following config must be added in the base application.yml
of the spring-boot service:
management:
endpoints:
web:
exposure:
include: * # health,prometheus
health:
show-details: always
You can be more granular on what endpoints you want to expose by replacing the *
with something more specific as per Spring's doco: Endpoints :: Spring Boot