GitHub - helpdeveloper/java-observability-metrics: [Java][Metrics] Observability metrics stack with Java (Quarkus and Spring Boot) + Micrometer + Prometheus + Grafana
Observability: Monitoring your application from metrics
This repository contains sample Spring Boot and Quarkus application that exposes metrics to Prometheus and Grafana.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
Architecture
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
Tecnologies:
- Java 17
- Spring Boot 3
- Quarkus 2.15
- Docker Compose
- Prometheus 2.26
- Grafana 9.3
Execution
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 installon 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}
Prometheus UI
- Running at: http://localhost:9090
- Config files: docker/prometheus
Grafana UI
- Running at: http://localhost:3000
- Config files: docker/grafana
Test the apps métrics
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 aboutdoProcessmethod durationhello_get_name_length_limit: Count metric increases when the Query Paramnameexceed the length limit (currently 10)
Call that endpoint:
$curl 'http://localhost:{port}/hello?name={any name}'
Monitoring
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
Contribute
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.
Developer
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 - gbzarelli@helpdev.com.br



