Skip to content

feat: Grafana Cloud 기반 로그 관리 시스템#26

Merged
mungmnb777 merged 15 commits into
mainfrom
feat/log-management
Jan 27, 2026
Merged

feat: Grafana Cloud 기반 로그 관리 시스템#26
mungmnb777 merged 15 commits into
mainfrom
feat/log-management

Conversation

@mungmnb777

@mungmnb777 mungmnb777 commented Jan 21, 2026

Copy link
Copy Markdown
Collaborator

요약

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에 초대드리겠습니다!

@mungmnb777 mungmnb777 self-assigned this Jan 21, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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를 docker-compose를 통해 통합하여, 실행 중인 Docker 컨테이너들의 로그를 자동으로 수집하고 Grafana Loki로 전송함으로써 시스템의 가시성을 향상시키는 것이 주된 목적입니다.

Highlights

  • GitHub Actions 파이프라인 변경: 기존의 단순 docker run 방식에서 Grafana Alloy 통합을 위해 docker-compose 기반으로 파이프라인이 수정되었습니다.
  • 새로운 docker 디렉토리 추가: 레포지토리 루트에 docker 디렉토리가 새로 추가되었으며, 여기에는 Dockerfile, Grafana Alloy 설정 파일, docker-compose.yml이 포함됩니다. 이는 기존에 레포지토리 외부에 관리되던 Dockerfile을 통합한 것입니다.
  • Grafana Alloy 로그 수집 방식 구현: Docker 컨테이너를 탐색하고, 컨테이너 이름을 기반으로 service_name 레이블을 지정하며, docker.sock을 통해 로그를 스크랩하여 Grafana Cloud Loki로 전송하는 로직이 config.alloy 파일에 정의되었습니다.

🧠 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
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/deploy-jar.yml
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

이 PR은 Grafana Alloy와 Docker Compose를 사용하여 Grafana Cloud 기반 로그 관리 시스템을 도입합니다. 전반적으로 로그 수집 통합을 위한 잘 구성된 설정으로 보입니다. 그러나 Docker 모범 사례, 환경 변수 처리 및 일관성과 관련하여 몇 가지 개선할 점이 있습니다.

Comment thread docker/docker-compose.yml Outdated
ports:
- "8080:8080"
env_file:
- ~/.env

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

env_file~/.env 경로를 사용하는 것은 docker-compose를 실행하는 사용자의 홈 디렉토리를 참조하는 절대 경로입니다. 이는 docker-compose.yml 파일을 이식성 없게 만들고 실행 환경에 의존하게 만듭니다. 환경 변수는 docker-compose.yml 파일에 상대적인 경로에서 가져오거나 직접 전달하는 것이 좋습니다.

      - ./.env

Comment thread docker/docker-compose.yml Outdated
restart: always

alloy:
image: grafana/alloy:latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

프로덕션 또는 배포 환경에서 Docker 이미지에 latest 태그를 사용하는 것은 위험합니다. latest 태그는 자주 변경될 수 있어 예기치 않은 동작, 호환성 문제 또는 빌드 재현성 문제를 야기할 수 있습니다. 특정 버전을 명시하는 것이 모범 사례입니다.

    image: grafana/alloy:0.10.0

Comment thread docker/Dockerfile Outdated

WORKDIR /

COPY ./build/libs/api-0.0.1-SNAPSHOT.jar /app.jar

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

배포용 Docker 이미지에서 SNAPSHOT 버전의 JAR 파일을 사용하는 것은 재현 불가능한 빌드를 초래할 수 있습니다. 프로덕션 환경에서는 고정된 릴리스 버전을 사용하거나 빌드 시점에 버전을 동적으로 주입하는 방식을 고려하는 것이 좋습니다.

Comment thread docker/alloy/.env.example Outdated
Comment on lines +1 to +3
GRAFANA_CLOUD_OTLP_URL=
GRAFANA_CLOUD_OTLP_USERNAME=
GRAFANA_CLOUD_OTLP_API_TOKEN=

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

이 OTLP 관련 환경 변수들(GRAFANA_CLOUD_OTLP_URL, GRAFANA_CLOUD_OTLP_USERNAME, GRAFANA_CLOUD_OTLP_API_TOKEN)은 .env.example에 정의되어 있지만 현재 config.alloy에서 사용되지 않습니다. 이는 혼란을 야기하거나 불필요한 구성을 초래할 수 있으므로, OTLP를 사용하지 않을 경우 제거하는 것을 고려해 주세요.

Comment thread docker/alloy/.gitignore Outdated
@@ -0,0 +1 @@
.env No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

파일 끝에 새 줄이 없습니다. 텍스트 파일의 경우 파일 끝에 새 줄을 추가하는 것이 일반적인 모범 사례입니다.

.env

Comment thread docker/alloy/config.alloy Outdated
password = env("GRAFANA_CLOUD_LOKI_API_TOKEN")
}
}
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

파일 끝에 새 줄이 없습니다. 텍스트 파일의 경우 파일 끝에 새 줄을 추가하는 것이 일반적인 모범 사례입니다.

}

@jjh2613

jjh2613 commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

확인하였습니다.

  1. grafana-alloy 에 대하여
  • 저도 grafana cloud 에 연동해본 적은 없어서 grafana alloy 방식은 사실은 처음 봐서 잘 모르겠습니다만 가능하다면, metric 은 보는 모니터링 의미가 커서 추가하면 좋을것 같습니다.
  • metric 은 다음에 추가해도 됩니다ㅎ
  1. docker 배포에 대하여
  • 그냥 코멘트입니다.
  • 명범님도 아실것 같지만, 보통은 이런 방식으로 CI / CD 를 하지는 않습니다. 사이드 프로젝트로는 훌륭하다고 생각하지만, 코드 리뷰라서 말씀드립니다.
  1. docker 이미지 관리에 대하여
  • 배포를 하는 횟수 X jar 파일 크기만큼 이미지 레이어들이 계속해서 쌓여 용량을 먹게 될것입니다.
  • 대안 1) jib 플러그인을 사용하여 이미지를 빌드하는 걸 추천드립니다. 그럼 docker 가 jar 레이어를 잘게 나누어서 배포 횟수에 대한 용량이 적어집니다.
  • 대안 2) docker-compose 적용 이후 docker image pruning 스크립트 한 줄 추가하여 안 쓰는 이미지는 컨테이너에서 없애버리는 것이 필요해보입니다.

@jjh2613

jjh2613 commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

코멘트는 남겼지만 크게 중요친 않습니다. 직접 머지해주셔도 좋습니다!! 감사합니다 :)

@mungmnb777

Copy link
Copy Markdown
Collaborator Author

이해했습니다!

그러고보니 예전에도 이거에 대해서 이야기했던 것 같은데, 이번에 도커 수정하는 김에 같이 수정하면 되겠네요

grafana alloy는 제가 Loki Appender를 스프링에서 제공해주는 걸 모르고 사용했었는데, 그냥 Logback에서 Loki Appender를 쓰는게 좀 더 간단하게 구현할 수 있었겠네요
감사합니다!

@mungmnb777 mungmnb777 merged commit 118676b into main Jan 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants