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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ dependencies {
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

// Prometheus
implementation 'io.micrometer:micrometer-registry-prometheus'
}

// Q클래스 생성 경로 설정
Expand Down
54 changes: 54 additions & 0 deletions deployment/docker-compose-monitoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: "3.8"

networks:
monitoring:
driver: bridge

services:
prometheus:
image: prom/prometheus:v3.5.1
container_name: prometheus
networks:
- monitoring
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus # 디스크에 데이터 저장
command:
- "--config.file=/etc/prometheus/prometheus.yml"
restart: unless-stopped

grafana:
image: grafana/grafana:12.4
container_name: grafana
networks:
- monitoring
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
depends_on:
- prometheus
- loki
restart: unless-stopped
Comment thread
hyomee2 marked this conversation as resolved.

loki:
image: grafana/loki:3.5.12
container_name: loki
networks:
- monitoring
ports:
- "3100:3100"
command: "-config.file=/etc/loki/config.yml"
volumes:
# Loki 설정 파일 컨테이너에 삽입 (read-only)
- ./loki/config.yml:/etc/loki/config.yml:ro
# 로그 데이터 디스크에 남김
- loki_data:/loki
restart: unless-stopped

volumes:
prometheus_data:
grafana_data:
loki_data:
21 changes: 21 additions & 0 deletions deployment/loki/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
auth_enabled: false # 인증 사용없이 Promtail이 바로 로그 보낼 수 있음
Comment thread
hyomee2 marked this conversation as resolved.

server:
http_listen_port: 3100 # Loki가 HTTP로 요청 받을 포트 (Promtail, Grafana에서 접근)

storage_config:
tsdb_shipper:
active_index_directory: /loki/tsdb-index
cache_location: /loki/tsdb-cache
filesystem:
directory: /loki/chunks # 로그 청크 데이터 저장 위치. Loki는 로그를 청크 단위로 저장

schema_config: # Loki 내부 스키마 설정
configs:
- from: 2026-03-20
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h # 하루 단위로 인덱스 파일 생성
Comment thread
hyomee2 marked this conversation as resolved.
10 changes: 10 additions & 0 deletions deployment/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
global:
scrape_interval: 15s
evaluation_interval: 15s

scrape_configs:
- job_name: 'kareer_server'
metrics_path: '/actuator/prometheus'
static_configs:
- targets: ['api.ka-reer.com:443'] # HTTPS를 통해 접근
scheme: https
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class SecurityConfig {
"/login/oauth2/**",
"/api/v1/job-postings/crawl",
"/api/v1/members/roadmap/test",
"/actuator/prometheus",
Comment thread
hyomee2 marked this conversation as resolved.
};

private final CustomAuthenticationEntryPoint authenticationEntryPoint;
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ auth:
same-site: ${AUTH_REFRESH_TOKEN_COOKIE_SAMESITE}
token-blacklist:
redis-prefix: ${AUTH_TOKEN_BLACKLIST_REDIS_PREFIX}

management:
endpoints:
web:
exposure:
include: health, info, prometheus
Comment thread
hyomee2 marked this conversation as resolved.
endpoint:
prometheus:
enabled: true
health:
show-details: always
Comment thread
hyomee2 marked this conversation as resolved.
---
spring:
config:
Expand Down
Loading