Skip to content

Commit

Permalink
feat: Promtail을 spring boot 서버와 동일 인스턴스에 배포되도록 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
sunghyuki committed Nov 19, 2024
1 parent 2f88c0d commit 1ab93a0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
19 changes: 17 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@ version: '3.8'

services:
climingo-api:
image: climingo/climingo:${TAG} # Spring Boot 애플리케이션 Docker 이미지
image: climingo/climingo:${TAG} # Spring Boot 애플리케이션 Docker 이미지
container_name: climingo-api
environment:
- JASYPT_PASSWORD=${JASYPT_PASSWORD}
- VERSION=${TAG}
- BUILDTIME=${BUILDTIME}
ports:
- "8080:8080"
logging: # 로그 드라이버 설정 (json-file 기본값 사용)
driver: "json-file"
options:
max-size: "10m"
max-file: "3"

promtail:
image: grafana/promtail:2.9.0 # Promtail Docker 이미지
container_name: promtail
depends_on:
- climingo-api # Spring Boot 애플리케이션이 먼저 실행되도록 설정
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/log:/var/log:ro # 필요하면 호스트 로그 디렉토리 마운트
- /var/lib/docker/containers:/var/lib/docker/containers:ro # Docker 컨테이너 로그 경로
- ./promtail-config.yml:/etc/promtail/promtail.yml:ro # Promtail 설정 파일
command:
- -config.file=/etc/promtail/promtail.yml # 설정 파일 위치
18 changes: 18 additions & 0 deletions promtail-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server:
http_listen_port: 9080 # Promtail HTTP 서버 포트

clients:
- url: http://ec2-43-200-200-208.ap-northeast-2.compute.amazonaws.com:3100/loki/api/v1/push # Loki 서버 URL

positions:
filename: /tmp/positions.yaml # 로그 수집 위치 저장 파일

scrape_configs:
- job_name: "climingo-api" # 작업 이름
static_configs:
- targets:
- ec2-3-35-66-48.ap-northeast-2.compute.amazonaws.com # Promtail 컨테이너가 실행되는 서버
labels:
job: "climingo-api" # 로그 구분 태그
service: "spring-boot" # 서비스 이름
__path__: /var/lib/docker/containers/*/*-json.log # Docker 로그 파일 경로

0 comments on commit 1ab93a0

Please sign in to comment.