Skip to content

Conversation

@lvalentine6
Copy link
Member

@lvalentine6 lvalentine6 commented Nov 30, 2025

✨ 개요

  • Datadog 콘솔 데이터들을 테라폼으로 관리합니다.
  • SLO와 연관된 알람을 디스코드 알람-주의 채널로 분리하였습니다.
  • 서비스 성능 지표, 보안, 비용이 포함된 월간 서버 리포트를 발행하는 기능을 추가하였습니다.

🧾 관련 이슈

#195

🔍 참고 사항 (선택)

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능
    • 월간 서버 운영 보고서 자동 생성 및 배포
    • 가용성 및 응답시간 기반 SLO 모니터링 추가
    • CPU, 메모리 사용률 모니터링 및 자동 알림 시스템 구축
    • Discord를 통한 실시간 경고 및 복구 알림

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link

📄 Terraform Plan Summary

🛡️ Common Infrastructure


No plan summary

Status: ✅ No Changes


🛠️ Development Environment


No plan summary

Status: ✅ No Changes


📋 Full Results: View in Actions

@coderabbitai
Copy link

coderabbitai bot commented Nov 30, 2025

Walkthrough

월별 운영 리포트 시스템을 도입하는 변경입니다. GitHub Actions 워크플로우가 매월 실행되어 Python 스크립트를 호출하면, 이 스크립트가 Datadog SLO 메트릭, AWS WAF 통계, AWS 비용 데이터를 수집한 후 Discord 웹훅으로 결과를 전송합니다. Datadog 공급자, SLO, 모니터 및 통합을 위한 Terraform 구성도 포함됩니다.

Changes

Cohort / File(s) 변경 요약
GitHub Actions 워크플로우
.github/workflows/monthly-server-report.yml
매월 1일 00:30 UTC에 실행되는 스케줄 워크플로우 추가. Python 3.10 설정, 의존성 설치(boto3, datadog-api-client, requests, python-dateutil), GitHub Secrets에서 환경 변수를 사용하여 scripts/monthly-server-report.py 실행
Python 리포트 스크립트
scripts/monthly-server-report.py
월별 운영 리포트 생성 스크립트 추가. Datadog SLO 가용성/지연 시간, AWS WAF 허용/차단 요청, AWS 월별 비용을 집계하고 한국어 포맷으로 Discord 웹훅에 전송. 각 API 호출마다 오류 처리 포함
Terraform Datadog 공급자
terraform/datadog/providers.tf
Datadog 및 AWS 공급자 블록 정의. Datadog API는 SSM 파라미터에서 자격증명 로드, API URL을 https://api.us5.datadoghq.com/로 설정
Terraform SLO 정의
terraform/datadog/slos.tf
두 개의 Service Level Objective 리소스 추가: eatda_latency (P95 < 500ms, 30일, 목표 99%), eatda_availability (가용성, 30일, 목표 99%)
Terraform 모니터
terraform/datadog/monitors.tf
네 개의 모니터 리소스 추가: CPU 사용률(임계값 90/70), 메모리 사용률(임계값 0.9/0.7), 가용성 Burn Rate, 지연 시간 SLO 모니터. 한국어/영어 메시지 템플릿 포함
Terraform 통합
terraform/datadog/integrations.tf
세 개의 Discord 웹훅 리소스 추가: discord_alert(색상 15548997), discord_warn(색상 16776960), discord-recovery(색상 5763719). 각각 SSM 파라미터에서 웹훅 URL 참조
Terraform 데이터 소스 및 로컬 변수
terraform/datadog/locals.tf
다섯 개의 SSM 파라미터 데이터 소스 추가(Datadog API/앱 키, Discord 웹훅 URL), 알림 푸터 로컬 변수 정의(CRITICAL/WARNING/RECOVERY 섹션)
Terraform 백엔드 및 구성
terraform/datadog/backend.tf, terraform/datadog/providers.tf
S3 백엔드 설정: 버킷 "eatda-tf-state", 키 "datadog/terraform.tfstate", 리전 "ap-northeast-2", DynamoDB 잠금 활성화
Terraform 구성 파일 (빈 파일)
terraform/datadog/{outputs.tf, variables.tf, terraform.tfvars}
향후 사용을 위한 빈 파일 추가
Terraform 잠금 파일
terraform/datadog/.terraform.lock.hcl
Datadog 공급자 v3.81.0, AWS 공급자 v6.23.0 해시 정보 추가

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Python 스크립트 (scripts/monthly-server-report.py): 여러 외부 API(Datadog, AWS WAF, Cost Explorer)와의 상호작용, 오류 처리, 데이터 정규화 로직 검토 필요
  • Terraform SLO 및 모니터 정의: 쿼리 문법, 임계값, 메시지 템플릿의 정확성 확인 필요
  • 환경 변수 및 보안: GitHub Secrets와 SSM 파라미터 사용의 올바른 연동 확인
  • API 통합: Datadog 웹훅 페이로드 형식, Discord 임베드 구조의 정확성 검증 필요

Poem

🐰 월간 리포트, 번들로 옷 입고
API들과 춤을 춘다, 아찔하게
Discord 창에 무지개색 메시지 휘날리고
Datadog 차트는 쏜살같이 날아와
AWS 비용? 웃으며 마주하자, 함께! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 변경사항의 주요 내용을 명확하게 요약합니다. Datadog 테라폼 적용과 월간 서버 리포트 추가라는 두 가지 핵심 기능이 정확히 반영되어 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/PRODUCT-281

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (5)
.github/workflows/monthly-server-report.yml (3)

1-1: 워크플로우 이름에서 파일 확장자를 제거하세요.

워크플로우 이름에 .yml 확장자가 포함되어 있는데, 이는 관례상 제거해야 합니다.

-name: monthly-server-report.yml
+name: monthly-server-report

20-22: 패키지 버전을 명시적으로 지정하세요.

재현 가능성을 위해 각 종속 패키지의 버전을 고정하는 것이 좋습니다.

-          pip install boto3 datadog-api-client requests python-dateutil
+          pip install boto3==1.28.0 datadog-api-client==1.20.0 requests==2.31.0 python-dateutil==2.8.2

최신 버전을 확인하려면 PyPI 레지스트리를 확인하세요.


24-32: scripts/monthly-server-report.py 스크립트가 존재하고 유효한지 확인하세요.

워크플로우에서 Python 스크립트를 실행하지만, 해당 스크립트가 제공되지 않아 검증할 수 없습니다. 다음 사항을 확인하세요:

  • 스크립트가 모든 필수 환경 변수를 올바르게 처리하는가?
  • Datadog API 호출 실패, 네트워크 오류, AWS 호출 실패에 대한 에러 처리가 있는가?
  • Discord 웹훅 전송 실패에 대한 재시도 로직이 있는가?

스크립트에 대한 일반적인 에러 처리 및 검증 로직을 생성하는 데 도움을 드릴 수 있습니다.

terraform/datadog/integrations.tf (1)

31-44: 웹훅 리소스 이름을 일관성 있게 지정하세요.

discord_alert, discord_warn과 달리 discord-recovery 리소스는 하이픈을 사용합니다. Terraform에서 리소스 이름에는 언더스코어를 사용하는 것이 관례입니다.

-resource "datadog_webhook" "discord-recovery" {
+resource "datadog_webhook" "discord_recovery" {

그리고 해당 참조를 업데이트하세요:

-  name = "discord-warn-channel-recovery"
+  name = "discord-warn-channel-recovery"
scripts/monthly-server-report.py (1)

157-157: 코드 스타일: 한 줄에 여러 문장

가독성을 위해 조건문과 할당을 분리하세요.

-    if total_req == 0: total_req = 1
+    if total_req == 0:
+        total_req = 1
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26b0da1 and 4f2e812.

📒 Files selected for processing (12)
  • .github/workflows/monthly-server-report.yml (1 hunks)
  • scripts/monthly-server-report.py (1 hunks)
  • terraform/datadog/.terraform.lock.hcl (1 hunks)
  • terraform/datadog/backend.tf (1 hunks)
  • terraform/datadog/integrations.tf (1 hunks)
  • terraform/datadog/locals.tf (1 hunks)
  • terraform/datadog/monitors.tf (1 hunks)
  • terraform/datadog/outputs.tf (1 hunks)
  • terraform/datadog/providers.tf (1 hunks)
  • terraform/datadog/slos.tf (1 hunks)
  • terraform/datadog/terraform.tfvars (1 hunks)
  • terraform/datadog/variables.tf (1 hunks)
🧰 Additional context used
🪛 Ruff (0.14.6)
scripts/monthly-server-report.py

67-67: Do not catch blind exception: Exception

(BLE001)


73-73: Do not catch blind exception: Exception

(BLE001)


84-84: Do not catch blind exception: Exception

(BLE001)


86-86: Do not catch blind exception: Exception

(BLE001)


114-114: Consider moving this statement to an else block

(TRY300)


115-115: Do not catch blind exception: Exception

(BLE001)


135-135: Consider moving this statement to an else block

(TRY300)


136-136: Do not catch blind exception: Exception

(BLE001)


157-157: Multiple statements on one line (colon)

(E701)


178-178: Probable use of requests call without timeout

(S113)


187-187: Do not catch blind exception: Exception

(BLE001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (16)
terraform/datadog/terraform.tfvars (1)

1-1: tfvars 파일이 비어있습니다 — 의도적인지 확인이 필요합니다.

이 파일은 현재 비어있지만, Terraform tfvars 파일은 일반적으로 모듈 변수의 값을 정의하는 데 사용됩니다. Datadog 모듈의 variables.tf에서 정의된 변수(Discord 웹훅 URL, 알림 채널, 리포트 설정 등)에 대한 값 할당이 필요한지 확인해주세요.

  • 모든 변수가 기본값으로 적절한지, 아니면 환경별 오버라이드가 필요한지 검토 필요
  • 만약 이 파일을 향후 사용 목적의 플레이스홀더로 의도하신 경우, 주석 또는 설명을 추가하는 것을 권장
terraform/datadog/outputs.tf (1)

1-1: outputs.tf 파일이 비어있습니다. 의도를 명확히 해주세요.

이 파일이 향후 Datadog 리소스 ID나 속성을 다른 Terraform 모듈에 노출하기 위한 placeholder인지, 아니면 제거해야 하는 파일인지 확인이 필요합니다. 일반적으로 Terraform 모듈에서 outputs을 내보낼 필요가 없다면 이 파일을 제거하는 것이 좋습니다.

다음 중 하나를 확인해주세요:

  • 이 Datadog 모듈이 다른 모듈에 내보낼 output이 있는가?
  • 없다면, 이 파일을 제거할 수 있는가?
terraform/datadog/variables.tf (1)

1-1: > Likely an incorrect or invalid review comment.

terraform/datadog/backend.tf (1)

1-9: 백엔드 구성 양호합니다.

S3 상태 저장소가 암호화되어 있고, DynamoDB 잠금이 구성되어 있어 상태 무결성이 보장됩니다.

terraform/datadog/.terraform.lock.hcl (1)

4-46: 제공자 버전이 적절합니다.

Datadog 3.81.0과 AWS 6.23.0 버전은 현재 안정적인 버전입니다. 잠금 파일이 존재하여 재현 가능성이 보장됩니다.

terraform/datadog/locals.tf (1)

21-40: 알림 푸터 템플릿이 Datadog 웹훅 통합과 일관성 있게 구성되었습니다.

Handlebars 조건문({{#is_alert}}, {{#is_warning}}, {{#is_recovery}})이 Datadog의 표준 템플릿 문법에 맞으며, 웹훅 채널 참조도 integrations.tf의 이름과 연계되어 있습니다.

terraform/datadog/slos.tf (1)

1-60: SLO 정의가 일관성 있고 명확합니다.

두 SLO 모두 목표값(99%)과 경고 임계값(99.5%)이 일치하며, 30일 기간으로 설정되어 있습니다. 가용성 쿼리는 5xx 에러와 플래그를 올바르게 제외하고 있습니다.

그러나 monitors.tf에서 하드코딩된 SLO ID가 이 리소스로 생성되는 SLO 후 일치하는지 확인해야 합니다. 아래를 검토하세요.

terraform/datadog/providers.tf (1)

1-18: 제공자 구성이 적절합니다.

Datadog와 AWS 제공자 버전이 잠금 파일과 일치하며, API 키가 SSM Parameter Store에서 안전하게 참조됩니다.

terraform/datadog/monitors.tf (3)

1-54: CPU 사용량 모니터가 올바르게 구성되었습니다.

쿼리 문법이 정확하고, 임계값(critical 90%, warning 70%)이 적절하며, 한글 메시지가 명확합니다.


56-107: 메모리 사용량 모니터가 올바르게 구성되었습니다.

쿼리 문법이 정확하고, 임계값(critical 0.9, warning 0.7)이 적절하며, 메시지가 명확합니다. on_missing_data를 "default"로 설정한 것은 좋은 선택입니다.


109-162: Verify SLO configuration parameters are correctly set.

The burn_rate window parameters and thresholds appear valid per Datadog constraints:

  • long_window="1h" is within the required 1–48 hour range
  • short_window="5m" is less than the long_window
  • threshold 14.4 is valid for 99% SLO target (max = 100)

However, clarify the reference to a "severe issue" mentioned in the original comment and confirm the hardcoded SLO ID c2ba09c7153a5bcd91e9ba4f92245579 is intentional or should be managed via variables/locals for maintainability.

scripts/monthly-server-report.py (5)

1-18: LGTM!

환경 변수를 통한 민감 정보 관리와 상수 정의가 적절합니다.


20-41: LGTM!

날짜 범위 계산 로직이 정확하며, 다양한 API 요구사항에 맞는 포맷을 제공합니다.


44-49: LGTM!

SLO 값 정규화 로직이 적절합니다. Datadog API가 0-1 범위의 비율 값을 반환할 경우 백분율로 변환합니다.


52-89: LGTM!

리포트 스크립트에서 개별 API 호출 실패 시에도 나머지 데이터를 수집하는 graceful degradation 패턴이 적절합니다. 광범위한 예외 처리(Exception)는 이 컨텍스트에서 허용됩니다.


125-138: LGTM!

Cost Explorer API는 us-east-1 리전에서만 작동하므로 하드코딩이 적절합니다. 예외 처리도 잘 되어 있습니다.

@lvalentine6 lvalentine6 merged commit 1997898 into develop Nov 30, 2025
11 checks passed
@lvalentine6 lvalentine6 deleted the feat/PRODUCT-281 branch November 30, 2025 19:55
@github-actions
Copy link

🎉 This PR is included in version 1.8.0-develop.19 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 1.9.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

2 participants