File tree Expand file tree Collapse file tree 9 files changed +3110
-6
lines changed
spring-prometheus-grafana-example
src/main/java/com/io/example/controller Expand file tree Collapse file tree 9 files changed +3110
-6
lines changed Original file line number Diff line number Diff line change 1- " component : spring-kafka-example" :
1+ " project : spring-kafka-example" :
22 - changed-files :
33 - any-glob-to-any-file : ' spring-kafka-example/**/*'
44
5+ " project: spring-prometheus-grafana-example " :
6+ - changed-files :
7+ - any-glob-to-any-file : ' spring-prometheus-grafana-example/**/*'
8+
59" type: dependency-upgrade " :
610 - changed-files :
7- - any-glob-to-any-file : spring-kafka-example/pom.xml
11+ - any-glob-to-any-file :
12+ - spring-kafka-example/pom.xml
13+ - spring-prometheus-grafana-example/pom.xml
814
915" ci: github-actions " :
1016 - changed-files :
Original file line number Diff line number Diff line change 5050 compose-file : ' ./spring-prometheus-grafana-example/compose.yaml'
5151 services : |
5252 app
53+ prometheus
54+ grafana
5355 up-flags : ' --build'
5456 down-flags : ' --volumes'
5557
@@ -58,13 +60,17 @@ jobs:
5860
5961 - name : Check container health
6062 run : |
61- echo "Verificando saúde dos containers..."
63+ echo "Checking the health of the containers..."
6264
6365 APP_STATUS=$(docker inspect -f '{{.State.Running}}' app || echo "false")
66+ PROMETHEUS_STATUS=$(docker inspect -f '{{.State.Running}}' prometheus || echo "false")
67+ GRAFANA_STATUS=$(docker inspect -f '{{.State.Running}}' grafana || echo "false")
6468
65- echo "Status do app: $APP_STATUS"
69+ echo "App status: $APP_STATUS"
70+ echo "Prometheus status: $PROMETHEUS_STATUS"
71+ echo "Grafana status: $GRAFANA_STATUS"
6672
67- if [ "$APP_STATUS" != "true" ]; then
73+ if [ "$APP_STATUS" != "true" ] || [ "$PROMETHEUS_STATUS" != "true" ] || [ "$GRAFANA_STATUS" != "true" ] ; then
6874 echo "::error ::An error occurred while executing the containers."
6975 exit 1
7076 fi
Original file line number Diff line number Diff line change 1+ # spring-prometheus-grafana-example
2+
3+ ---
4+
5+ ## Overview
6+
7+ This is a basic Java Spring project demonstrating how to integrate Prometheus and Grafana
8+ to collect and visualize application metrics from a Spring Boot application.
9+ Metrics are exposed via Spring Actuator and scraped by Prometheus, which are then displayed
10+ in customizable dashboards using Grafana.
11+
12+ ---
13+
14+ ## Tech stack
15+
16+ - Spring Boot
17+ - Spring Actuator
18+ - Java 21
19+ - Prometheus (Docker)
20+ - Grafana (Docker)
21+
22+ ---
23+
24+ ## Ports
25+
26+ | Service | Local URL | Username/Password |
27+ | ------------| ------------------------------------------------| -------------------|
28+ | Prometheus | [ http://localhost:9090 ] ( http://localhost:9090 ) | n/a |
29+ | Grafana | [ http://localhost:3000 ] ( http://localhost:3000 ) | admin/admin |
30+
31+ ---
32+
33+ ## Related Resources
34+
35+ | Description | Link |
36+ | --------------------------------------------| -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
37+ | Basic config spring + grafana + prometheus | [ monitoring-spring-boot-applications-with-prometheus-and-grafana] ( https://hidev.cc/tutoriais-praticos/2025/03/monitorando-aplicacoes-spring-boot-com-prometheus-e-grafana/ ) |
38+ | Grafana Dashboards Spring boot | [ grafana.com/grafana/dashboards] ( https://grafana.com/grafana/dashboards/?search=spring+boot ) |
39+
40+ ---
41+
42+ ## Dashboards Configured
43+
44+ | Name | File Path | Source |
45+ | -------------------------| ------------------------------------------------| ----------------------------------------------------------------------------------------|
46+ | Spring Boot JVM Metrics | ` docker/dashboards/jvm-metrics-dashboard.json ` | [ Grafana Dashboard #4701 ] ( https://grafana.com/grafana/dashboards/4701-jvm-micrometer/ ) |
47+
48+ ---
Original file line number Diff line number Diff line change @@ -5,5 +5,35 @@ services:
55 container_name : app
66 build :
77 context : .
8+ environment :
9+ SERVER_PORT : 80
10+ SPRING_PROFILES_ACTIVE : prd
811 ports :
9- - " 80:80"
12+ - " 80:80"
13+
14+ prometheus :
15+ container_name : prometheus
16+ image : prom/prometheus:v3.5.0
17+ ports :
18+ - " 9090:9090"
19+ volumes :
20+ - ./docker/prometheus.yml:/etc/prometheus/prometheus.yml
21+ command :
22+ - ' --config.file=/etc/prometheus/prometheus.yml'
23+ depends_on :
24+ - app
25+
26+ grafana :
27+ container_name : grafana
28+ image : grafana/grafana:12.1.0
29+ ports :
30+ - " 3000:3000"
31+ depends_on :
32+ - prometheus
33+ environment :
34+ - GF_SECURITY_ADMIN_USER=admin # ⚠️ DO NOT USE IN PRODUCTION
35+ - GF_SECURITY_ADMIN_PASSWORD=admin # ⚠️ DO NOT USE IN PRODUCTION
36+ volumes :
37+ - ./docker/provisioning/datasources:/etc/grafana/provisioning/datasources
38+ - ./docker/provisioning/dashboards:/etc/grafana/provisioning/dashboards
39+ - ./docker/dashboards:/var/lib/grafana/dashboards
You can’t perform that action at this time.
0 commit comments