Skip to content

Conversation

@wibaek
Copy link
Member

@wibaek wibaek commented Apr 15, 2025

관련 이슈

작업 내용

  1. prod, stage 환경에서 로그를 파일로 내보내게 설정했습니다
  2. prod, stage 환경에서 Alloy 컨테이너를 띄워 자동으로 파일 내용을 읽고 그라파나/로키 서버로 보내게 했습니다

로컬에서 테스트해서 작동되는지 확인했습니다!

특이 사항

리뷰 요구사항 (선택)

@wibaek wibaek self-assigned this Apr 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Apr 15, 2025

Walkthrough

  1. .gitignore 파일 변경
     - logs/ 디렉터리가 새롭게 추가되어 Git이 해당 로그 폴더와 그 안의 모든 파일을 버전 관리에서 무시하도록 설정되었습니다.

  2. docker-compose.prod.yml 파일 변경
     - solid-connection-server 서비스에 ./logs 디렉터리를 컨테이너 내 /var/log/spring 경로로 마운트하는 볼륨 설정이 추가되었습니다.
     - 새로운 alloy 서비스가 추가되어 grafana/alloy:latest 이미지를 사용하며, 컨테이너 이름은 alloy로 지정되었습니다.
     - alloy 서비스는 호스트와 컨테이너 양쪽에서 포트 12345를 열고, 동일한 ./logs 디렉터리를 /var/log/spring에 마운트합니다.
     - alloy 서비스는 환경 변수 ALLOY_ENVproduction으로 설정합니다.
     - alloy 서비스는 읽기 전용으로 ./docs/config.alloy 파일을 컨테이너 내 /etc/alloy/config.alloy 경로에 마운트합니다.

  3. docker-compose.stage.yml 파일 변경
     - 기존 solid-connection-stage 서비스에 ./logs 디렉터리를 컨테이너 내 /var/log/spring 경로로 마운트하는 볼륨 설정이 추가되었습니다.
     - 새로운 alloy 서비스가 추가되어 grafana/alloy:latest 이미지를 사용하며, 컨테이너 이름은 alloy로 지정되었습니다.
     - alloy 서비스는 호스트와 컨테이너 양쪽에서 포트 12345를 열고, 동일한 ./logs 디렉터리를 /var/log/spring에 마운트합니다.
     - alloy 서비스는 환경 변수 ALLOY_ENVstage로 설정합니다.
     - alloy 서비스는 읽기 전용으로 ./docs/config.alloy 파일을 컨테이너 내 /etc/alloy/config.alloy 경로에 마운트합니다.

  4. docs/config.alloy 파일 추가
     - 로깅 및 모니터링을 위한 Alloy 구성 파일이 새롭게 도입되었습니다.
     - /var/log/spring/*.log 경로에 위치한 로그 파일들을 대상으로 매칭하며, 이 로그들을 Loki로 전송하도록 설정되어 있습니다.
     - 로그에 service=backend 라벨과 환경 변수 ALLOY_ENV 값에 따른 env 라벨이 추가됩니다.
     - 지정된 Loki 엔드포인트(http://monitor.solid-connection.com:3100/loki/api/v1/push)로 로그가 전송되며, 배치 전송 설정도 포함되어 있습니다.

  5. src/main/resources/logback-spring.xml 파일 추가
     - Spring Boot 애플리케이션의 로깅을 위한 Logback 설정 파일이 새롭게 추가되었습니다.
     - 콘솔과 롤링 파일(Appender) 설정이 포함되어 있으며, 로그는 /var/log/spring/solid-connection-server.log에 기록되고 최대 30일간 보관됩니다.
     - 로그 포맷은 Loki 수집에 최적화된 key=value 스타일이며, Spring 프로파일에 따라 콘솔 또는 파일로 로그가 출력됩니다.
     - 설정 파일은 60초마다 자동으로 재적용됩니다.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c0d52c and 7f844c8.

📒 Files selected for processing (3)
  • docker-compose.prod.yml (1 hunks)
  • docker-compose.stage.yml (1 hunks)
  • docs/config.alloy (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • docs/config.alloy
  • docker-compose.stage.yml
  • docker-compose.prod.yml
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@Gyuhyeok99 Gyuhyeok99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alloy로 변경하셨군요!

Copy link
Collaborator

@nayonsoso nayonsoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alloy가 비교적 최신 기술이라 자칫 이해하기 힘들수도 있는데,
달아주신 주석 덕분에 이해가 수월했습니다 ㅎㅎ

💁🏻‍♀️💁🏻‍♀️ 그리고 위백님이 블로그에 정리하신 내용을 위키에도 적으면 좋을 것 같은데 어떤가요?

Comment on lines 19 to 28
loki.process "spring_labels" {
forward_to = [loki.write.grafana_loki.receiver] // 처리된 로그를 Loki로 전송

stage.static_labels {
values = {
"job" = "spring",
"service" = "backend",
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 알기로, (그리고 혹시 몰라 지피티한테도 물어보기도 했는데요)
로키는 로그를 "라벨의 조합"으로만 구분해서,
이렇게 할 경우 stage의 로그와 production의 로그가 한 곳에 섞일수도 있을 것 같습니다..!

혹시 모르니 이렇게 설정하신 후, 🔥실제 그라파나에서 어떻게 동작하는지 확인해보시는게 필요할 것 같습니다.🔥

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇네요! 이전 Promtail 로그와 섞여서 문제가 있는걸 발견하지 못했네요. 확인해주셔서 감사합니다!

로키 로그도 비우고 환경내용도 로그에 포함시키도록 하겠습니다!

batch_wait = "1s" // 로그 배치 전송 대기 시간
batch_size = "1MB" // 로그 배치 크기
}
} No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOF 개행해주세요😊

@wibaek
Copy link
Member Author

wibaek commented Apr 27, 2025

alloy가 비교적 최신 기술이라 자칫 이해하기 힘들수도 있는데,

달아주신 주석 덕분에 이해가 수월했습니다 ㅎㅎ

💁🏻‍♀️💁🏻‍♀️ 그리고 위백님이 블로그에 정리하신 내용을 위키에도 적으면 좋을 것 같은데 어떤가요?

네! 블로그 내용 좀더 보강하고 위키에도 적어두도록 하겠습니다!

@wibaek wibaek merged commit daea588 into solid-connection:develop Apr 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

로그를 저장한다

3 participants