feat: Grafana Cloud 기반 로그 관리 시스템#26
Conversation
- 런타임 Dockerfile 추가 - compose로 maple-api + alloy 동시 구동 - Alloy가 Docker 로그를 Grafana Cloud Loki로 전송
Summary of ChangesHello @mungmnb777, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 Grafana Cloud를 활용한 로그 관리 시스템을 구축합니다. Grafana Alloy를 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
| ports: | ||
| - "8080:8080" | ||
| env_file: | ||
| - ~/.env |
| restart: always | ||
|
|
||
| alloy: | ||
| image: grafana/alloy:latest |
|
|
||
| WORKDIR / | ||
|
|
||
| COPY ./build/libs/api-0.0.1-SNAPSHOT.jar /app.jar |
| GRAFANA_CLOUD_OTLP_URL= | ||
| GRAFANA_CLOUD_OTLP_USERNAME= | ||
| GRAFANA_CLOUD_OTLP_API_TOKEN= |
| @@ -0,0 +1 @@ | |||
| .env No newline at end of file | |||
| password = env("GRAFANA_CLOUD_LOKI_API_TOKEN") | ||
| } | ||
| } | ||
| } No newline at end of file |
|
확인하였습니다.
|
|
코멘트는 남겼지만 크게 중요친 않습니다. 직접 머지해주셔도 좋습니다!! 감사합니다 :) |
|
이해했습니다! 그러고보니 예전에도 이거에 대해서 이야기했던 것 같은데, 이번에 도커 수정하는 김에 같이 수정하면 되겠네요 grafana alloy는 제가 Loki Appender를 스프링에서 제공해주는 걸 모르고 사용했었는데, 그냥 Logback에서 Loki Appender를 쓰는게 좀 더 간단하게 구현할 수 있었겠네요 |
요약
Grafana Cloud에서 로그를 확인할 수 있는 시스템을 만들었습니다.
구현 내용 사항
1. github actions 파이프라인이 수정되었습니다.
기존에는 단순 빌드 및
docker run명령어를 통해 서버를 실행시켰습니다.이번 변경 사항으로 Grafana Alloy를 현재 레포에서 추가로 관리하게 되면서, docker-compose를 사용하도록 변경했습니다.
2. 루트 디렉토리에 docker 디렉토리가 생성되었습니다.
기존에는 Dockerfile을 EC2 내부에 넣어놓고 레포에는 공개를 하지 않았는데, 생각해보니 굳이 그럴 필요가 없을 것 같아서 포함했습니다.
추가로 Grafana Alloy 관련 설정과 docker-compose.yml도 포함됩니다.
(.env 파일은 EC2내에서 미리 생성해뒀습니다.)
3. Alloy에서 로그를 수집하는 방식은 아래와 같습니다.
(1) 전체 컨테이너 탐색
(2) 컨테이너 이름으로 레이블링(Loki에서
service_name = <container_name>으로 조회하기 위함입니다.)(3) docker.sock을 통한 로그 스크랩 (이를 위해 docker.sock을 Alloy 컨테이너에 마운트합니다.)
(4) Loki로 전송
비고
이메일 주소 알려주시면 Grafana Cloud에 초대드리겠습니다!