The goal of this project was to showcase how to instrumentation your application and collect and monitor application's metrics running inside docker compose.
More detail in this article written in PT-BR: Observabilidade: Monitorando sua aplicação a partir de métricas
The project contains the following components:
- Spring Boot Web Application: To export metrics
- Quarkus Web Application: To export metrics
- Prometheus: To collect metrics
- Grafana: To data visualization
- Java 17
- Spring Boot 3
- Quarkus 2.15
- Docker Compose
- Prometheus 2.26
- Grafana 9.3
We have two docker-compose files to separate the stack and applications
To facilitate the execution of this example, we created a Makefile script with the following instructions:
- build: Execute build
mvnw clean install
on projects - install: Build the projects
Dockerfile
- run-stack: Execute only
docker-compose-stack.yml
- run-apps: Execute only
docker-compose-apps.yml
- run-all: Execute all steps above
- stop-stack: Stop stack
- stop-apps: Stop apps
- stop-all: Stop stack and apps
Execute the desired instruction:
$make {desired-instruction}
- Running at: http://localhost:9090
- Config files: docker/prometheus
- Running at: http://localhost:3000
- Config files: docker/grafana
Spring Boot: http://localhost:8081 Quarkus: http://localhost:8080
Both have a /hello
endpoint with a Query Param name
which will be metrified. The custom metrics generated are:
hello_get_method_timer
: Time metric about method durationhello_get_do_process_timer
: Time metric aboutdoProcess
method durationhello_get_name_length_limit
: Count metric increases when the Query Paramname
exceed the length limit (currently 10)
Call that endpoint:
$curl 'http://localhost:{port}/hello?name={any name}'
We have Grafana as monitoring in conjunction with Prometheus listening to the metrics of the applications, a default dashbord was created that automatically goes up in Grafana; (dashboards location)
- JVM (Micrometer) Dashboard
- Application Metrics Dashboard
Pull Requests are welcome. For important changes, open an 'issue' first to discuss what you would like to change. Be sure to update tests as appropriate.
Guilherme Biff Zarelli
Blog/Site - https://helpdev.com.br
LinkedIn - https://linkedin.com/in/gbzarelli/
GitHub - https://github.com/gbzarelli
Medium - https://medium.com/@guilherme.zarelli
Email - [email protected]