Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ jobs:
token: ${{ secrets.GIT_ACTION_TOKEN }}
submodules: true

- name: Copy docker-compose.yml to Server
- name: Copy compose & prometheus.yml to Server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "docker-compose.yml"
source: "docker-compose.yml,prometheus.yml"
target: "~/app"

- name: Deploy on server
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ dependencies {
// Flyway
implementation 'org.flywaydb:flyway-core'
implementation 'org.flywaydb:flyway-mysql'

// Grafana & Prometheus
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
}

tasks.named('test') {
Expand Down
66 changes: 63 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ services:
depends_on:
- app
- dozzle
- grafana
- prometheus
networks:
- danchu-network
restart: unless-stopped
Expand All @@ -74,9 +76,66 @@ services:
image: amir20/dozzle:latest
container_name: dozzle
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro # 로그 접근을 위한 도커 소켓 마운트
- /var/run/docker.sock:/var/run/docker.sock:ro # 로그 접근을 위한 도커 소켓 마운트
networks:
- danchu-network
- danchu-network
restart: unless-stopped

grafana:
image: grafana/grafana
container_name: grafana
environment:
- GF_SERVER_ROOT_URL=https://grafana.danchu.site/
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- grafana-storage:/var/lib/grafana
networks:
- danchu-network
restart: unless-stopped

prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
networks:
- danchu-network
restart: unless-stopped

node-exporter:
image: prom/node-exporter
container_name: node-exporter
command:
- '--path.rootfs=/host'
volumes:
- '/:/host:ro,rslave'
networks:
- danchu-network
restart: unless-stopped

mysqld-exporter:
image: prom/mysqld-exporter:v0.14.0
container_name: mysqld-exporter
environment:
- DATA_SOURCE_NAME=exporter:${MYSQL_EXPORTER_PASSWORD}@(mysql:3306)/danchu
depends_on:
mysql:
condition: service_healthy
networks:
- danchu-network
restart: unless-stopped

redis-exporter:
image: oliver006/redis_exporter:v1.67.0
container_name: redis-exporter
environment:
- REDIS_ADDR=redis:6379
depends_on:
redis:
condition: service_healthy
networks:
- danchu-network
restart: unless-stopped

networks:
Expand All @@ -85,4 +144,5 @@ networks:

volumes:
mysql-data:
redis-data:
redis-data:
grafana-storage:
49 changes: 49 additions & 0 deletions prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
global:
scrape_interval: 5s
evaluation_interval: 5s
scrape_timeout: 4s

scrape_configs:
# Prometheus
- job_name: 'prometheus'
static_configs:
- targets: ['prometheus:9090']
labels:
application: prometheus
service: prometheus

# Spring Boot
- job_name: 'danchu'
metrics_path: /actuator/prometheus
static_configs:
- targets: ['app:8080']
labels:
application: danchu
service: app
component: spring-boot

# node-exporter
- job_name: 'node-exporter'
static_configs:
- targets: ['node-exporter:9100']
labels:
application: danchu
service: node-exporter

# MySQL
- job_name: 'mysql'
static_configs:
- targets: ['mysqld-exporter:9104']
labels:
application: danchu
service: mysql
component: exporter

# Redis
- job_name: 'redis'
static_configs:
- targets: ['redis-exporter:9121']
labels:
application: danchu
service: redis
component: exporter
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.permitAll()
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**")
.permitAll()
.requestMatchers("/actuator/health", "/actuator/info", "/actuator/prometheus")
.permitAll()
.anyRequest()
.authenticated())
.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources