feat: Prometheus 스크랩 타겟을 EC2 프라이빗 IP로 변경#767
Conversation
|
Warning Review limit reached
More reviews will be available in 47 minutes and 22 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
워크스루이번 PR은 GitHub Actions CD 워크플로우 두 곳에서 Prometheus 스크랩 타겟 설정 방식을 변경했습니다.
예상 코드 리뷰 노력🎯 2 (Simple) | ⏱️ ~5 minutes 제안 리뷰어
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6729f22193
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/dev-cd.yml:
- Around line 197-205: The PRIVATE_IP variable assignment on lines 197-200 lacks
error handling, so if the ssh/curl command fails or returns empty, the
subsequent Prometheus target update on lines 203-205 will still execute with an
invalid or empty PRIVATE_IP value, creating malformed targets in stage.json. Add
a validation check after the PRIVATE_IP assignment to ensure the variable is not
empty, and only proceed with the Prometheus target update command if PRIVATE_IP
contains a valid value. If PRIVATE_IP is empty or invalid, the workflow should
fail fast to prevent corrupted monitoring configuration.
In @.github/workflows/prod-cd.yml:
- Around line 208-216: The workflow retrieves PRIVATE_IP from the IMDS endpoint
but does not validate that the value was successfully obtained before using it
to update the Prometheus target configuration in prod.json. Add validation after
the IMDS curl command to check that PRIVATE_IP is not empty, and fail the
workflow with an appropriate error message if the IMDS query fails or returns an
empty value. The ssh command that updates prod.json should only execute after
successful PRIVATE_IP validation to prevent saving invalid monitoring targets in
the production environment.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 2d4f85eb-5c49-4263-9c51-3f36b4056cf8
📒 Files selected for processing (2)
.github/workflows/dev-cd.yml.github/workflows/prod-cd.yml
lsy1307
left a comment
There was a problem hiding this comment.
수고하셨습니다! 보안그룹 설정은 변경안해도 되는지 궁금하네요..?
해당 인바운드 규칙은 기존에 이미 보안그룹을 대상으로 동작하기에 변경 없이도 동작합니다! |
관련 이슈
작업 내용
prod-cd.yml/dev-cd.yml의 Prometheus 타겟 파일 갱신 시 사용하는 app 서버 IP를 퍼블릭 IP(HOST/DEV_HOST시크릿)에서 EC2 프라이빗 IP로 변경했습니다.프라이빗 IP는 EC2 IMDS(Instance Metadata Service) 엔드포인트를 통해 조회합니다.
작업 근거
기존 방식은 monitoring 서버와 app 서버가 동일 VPC에 있음에도 퍼블릭 IP를 Prometheus 타겟으로 사용하고 있었습니다. 이 경우 Prometheus 스크랩 트래픽이 인터넷 게이트웨이를 경유하게 되어 아래 문제가 발생합니다.
프라이빗 IP를 사용하면 트래픽이 VPC 내부에서만 통신하므로 두 문제 모두 해결됩니다.
특이 사항
IMDS 주소(
169.254.169.254) 하드코딩에 대해169.254.x.x는 link-local 주소 대역으로 인터넷 라우팅이 불가능하며, EC2 인스턴스 내부에서만 접근할 수 있습니다. 또한 모든 EC2 인스턴스에 동일하게 적용되는 AWS 공식 문서 공개 엔드포인트이므로, 코드에 노출되어도 특정 인프라 정보가 드러나지 않아 보안상 문제없습니다.조회 경로를
/latest/meta-data/local-ipv4로 한정하므로 반환값은 프라이빗 IP뿐이며, IAM 자격증명 등 민감 정보와는 무관합니다.