Skip to content

Commit d91d738

Browse files
Merge pull request #32 from vimal-tech-starter/feature/phase-9-observability
Phase 9: Add Micrometer + Prometheus metrics support + Grafana visual dashboards
2 parents 41c68c4 + bc5e156 commit d91d738

5 files changed

Lines changed: 60 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ logs/
2323
############################################
2424
# Environment / Secrets
2525
############################################
26-
.env
26+
.env.dev
2727
.env.*
2828
*.env
2929
*.key

docker-compose.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.9"
2-
31
services:
42

53
postgres:
@@ -15,7 +13,7 @@ services:
1513
volumes:
1614
- vimaltech_pgdata:/var/lib/postgresql/data
1715
healthcheck:
18-
test: [ "CMD-SHELL", "pg_isready -U contactuser -d contactdb" ]
16+
test: ["CMD-SHELL", "pg_isready -U contactuser -d contactdb"]
1917
interval: 10s
2018
timeout: 5s
2119
retries: 5
@@ -28,9 +26,30 @@ services:
2826
condition: service_healthy
2927
ports:
3028
- "8080:8080"
29+
env_file:
30+
- .env.prod
3131
environment:
32-
SPRING_PROFILES_ACTIVE: dev
32+
SPRING_PROFILES_ACTIVE: prod
33+
restart: unless-stopped
34+
35+
prometheus:
36+
image: prom/prometheus
37+
container_name: vimaltech-prometheus
38+
volumes:
39+
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
40+
ports:
41+
- "9090:9090"
42+
restart: unless-stopped
43+
44+
grafana:
45+
image: grafana/grafana
46+
container_name: vimaltech-grafana
47+
ports:
48+
- "3000:3000"
49+
volumes:
50+
- grafana_data:/var/lib/grafana
3351
restart: unless-stopped
3452

3553
volumes:
36-
vimaltech_pgdata:
54+
vimaltech_pgdata:
55+
grafana_data:

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@
110110
<groupId>org.springframework.boot</groupId>
111111
<artifactId>spring-boot-starter-data-redis</artifactId>
112112
</dependency>
113+
114+
<dependency>
115+
<groupId>org.springframework.boot</groupId>
116+
<artifactId>spring-boot-starter-actuator</artifactId>
117+
</dependency>
118+
119+
<dependency>
120+
<groupId>io.micrometer</groupId>
121+
<artifactId>micrometer-registry-prometheus</artifactId>
122+
</dependency>
113123
</dependencies>
114124

115125
<build>

prometheus/prometheus.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
global:
2+
scrape_interval: 15s
3+
4+
scrape_configs:
5+
- job_name: 'contact-api'
6+
7+
metrics_path: /actuator/prometheus
8+
9+
static_configs:
10+
- targets: ['contact-api:8080']

src/main/resources/application-prod.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,18 @@ logging:
3535
root: WARN
3636
com.vimaltech.contactapi: INFO
3737
org.springframework: WARN
38-
org.hibernate: WARN
38+
org.hibernate: WARN
39+
40+
management:
41+
endpoints:
42+
web:
43+
exposure:
44+
include: health,info,prometheus
45+
46+
endpoint:
47+
health:
48+
show-details: never
49+
50+
metrics:
51+
tags:
52+
application: contact-api

0 commit comments

Comments
 (0)