Demo project for Monitoring
watch -n 1 http -a user:password monitoring-demo.localhost/
watch http -a user:password monitoring-demo.localhost/hello
for counter in {1..5}; do http -a user:password monitoring-demo.localhost/db & done
- present demo app endpoints - /, /hello, /db
- start bash requests
- show that, with no probes configured, we have periods of unavailability
-
pom.xml - add actuator dependency
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
-
test /actuator
-
add exemption for authentication for /health so that it can be used in k8s probes
it.requestMatchers(EndpointRequest.to(HealthEndpoint::class.java)).permitAll()
-
configure k8s sts to use probes (liveness, readiness, deploy, show slow startup)
livenessProbe: httpGet: port: http path: /actuator/health/liveness failureThreshold: 3 readinessProbe: httpGet: port: http path: /actuator/health/readiness periodSeconds: 60 failureThreshold: 1
-
configure startup
startupProbe: httpGet: port: http path: /actuator/health/readiness failureThreshold: 100 periodSeconds: 1
-
deploy, show fast start and endpoints: ../liveness & ../readiness
-
show details when authorized
management: endpoint: health: show-details: when_authorized
-
turn off the database, show that liveness & readiness do not fail
-
include db into readiness
management: endpoint: health: show-details: when_authorized group: readiness: include: - readinessState - db
-
pom.xml - add micrometer dependency
<dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency>
-
expose prometheus endpoint
endpoints: web: exposure: include: - info - health - prometheus
-
add security exemption for metrics
it.requestMatchers(EndpointRequest.to(InfoEndpoint::class.java, HealthEndpoint::class.java, PrometheusScrapeEndpoint::class.java)).permitAll()
- start requests for / and /hello
- show servicemonitor
- show prometheus & queries
- show grafana dashboard