Spring Boot 2 supports producing performance metrics in a Prometheus format using the Micrometer library (https://micrometer.io). There's only one change we need to make to the source code: we need to add a dependency to the Micrometer library, micrometer-registry-prometheus, in the Gradle build files, build.gradle, for each microservice. Here, the following dependency has been added:
implementation("io.micrometer:micrometer-registry-prometheus")
This will make the microservices produce Prometheus metrics on port 4004 using the "/actuator/prometheus" URI. To let Prometheus know about these endpoints, each microservice's pod is annotated with the following code:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "4004"
prometheus.io...