api-service already exposes all metrics except Prometheus. Now we need to add a micrometer library and change api-service to expose a separate Prometheus endpoint to export the metrics in a format accepted by Prometheus.
Once Prometheus endpoints start producing metrics data, we can configure Prometheus server to pull metrics data from the API service's /actuator/prometheus endpoint.
We'll take the following steps to integrate api-service with Prometheus. We'll start by making a few modifications in api-service:
- Maven dependency: First, we'll add the micrometer-registry-prometheus