This is a demo console app using Spring Boot 2.2 with Micrometer to publish metrics to Prometheus using Prometheus Push Gateway.
The Prometheus Pushgateway exists to allow ephemeral and batch jobs to expose their metrics to Prometheus. Since these kinds of jobs may not exist long enough to be scraped, they can instead push their metrics to a Pushgateway. The Pushgateway then exposes these metrics to Prometheus.
Using the docker-compose
command setup the necessary services
cd setup
docker-compose up
Using the docker-compose
command setup the necessary services
cd setup-security
docker-compose up
This will setup Prometheus & PushGateway instances
Second, open the browser and access the address
- Prometheus :
http://localhost:9090
- PushGateway :
http://localhost:9091
(9092 incase basic auth is enabled)
Start the application
mvn spring-boot:run
with security enabled, this will use basic authentication to connect to push-gateway
mvn spring-boot:run -Drun.profiles=secure
NOTE: make you the basic auth credentials used in htpasswd
and application.yml
are same.
Once the application has completed running,
Open the Prometheus Push Gateway http://localhost:9091
and see the metrics, mainly the hello_counter
You can also open Prometheus dashboard http://localhost:9090
to check the metrics