File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -28,5 +28,15 @@ services:
2828 - SPRING_PROFILES_ACTIVE=prod
2929 - SPRING_DATA_REDIS_HOST=redis
3030 - SPRING_DATA_REDIS_PORT=6379
31+ volumes :
32+ - ./logs:/var/log/spring
3133 depends_on :
3234 - redis
35+
36+ alloy :
37+ image : grafana/alloy:latest
38+ container_name : alloy
39+ ports :
40+ - " 12345:12345"
41+ volumes :
42+ - ./logs:/var/log/spring
Original file line number Diff line number Diff line change @@ -28,6 +28,16 @@ services:
2828 - " 8080:8080"
2929 environment :
3030 - SPRING_PROFILES_ACTIVE=stage
31+ volumes :
32+ - ./logs:/var/log/spring
3133 depends_on :
3234 - redis
3335 network_mode : host
36+
37+ alloy :
38+ image : grafana/alloy:latest
39+ container_name : alloy
40+ ports :
41+ - " 12345:12345"
42+ volumes :
43+ - ./logs:/var/log/spring
Original file line number Diff line number Diff line change 1+ livedebugging {
2+ enabled = true
3+ }
4+
5+ logging {
6+ level = "info"
7+ format = "logfmt"
8+ }
9+
10+ local.file_match "spring_logs" {
11+ path_targets = [{ __path__ = "/var/log/spring/*.log" }] // 서비스 로그 파일 경로
12+ }
13+
14+ loki.source.file "spring_source" {
15+ targets = local.file_match.spring_logs.targets // 위에서 정의한 로그 파일 경로 사용
16+ forward_to = [loki.process.spring_labels.receiver] // 읽은 로그를 처리 단계로 전달
17+ }
18+
19+ loki.process "spring_labels" {
20+ forward_to = [loki.write.grafana_loki.receiver] // 처리된 로그를 Loki로 전송
21+
22+ stage.static_labels {
23+ values = {
24+ "job" = "spring",
25+ "service" = "backend",
26+ }
27+ }
28+ }
29+
30+ loki.write "grafana_loki" {
31+ endpoint {
32+ url = "http://monitor.solid-connection.com:3100/loki/api/v1/push"
33+ tenant_id = "fake" // Loki 테넌트 ID (싱글 테넌시이기에 fake로 설정)
34+ batch_wait = "1s" // 로그 배치 전송 대기 시간
35+ batch_size = "1MB" // 로그 배치 크기
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments