[Feat] Datadog 테라폼 적용 및 월간 서버 리포트 추가#214
Conversation
…m-1-BE into feat/PRODUCT-281
📄 Terraform Plan Summary🛡️ Common InfrastructureStatus: ✅ No Changes 🛠️ Development EnvironmentStatus: ✅ No Changes 📋 Full Results: View in Actions |
Walkthrough월별 운영 리포트 시스템을 도입하는 변경입니다. GitHub Actions 워크플로우가 매월 실행되어 Python 스크립트를 호출하면, 이 스크립트가 Datadog SLO 메트릭, AWS WAF 통계, AWS 비용 데이터를 수집한 후 Discord 웹훅으로 결과를 전송합니다. Datadog 공급자, SLO, 모니터 및 통합을 위한 Terraform 구성도 포함됩니다. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ 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.
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
📒 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
c2ba09c7153a5bcd91e9ba4f92245579is 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 리전에서만 작동하므로 하드코딩이 적절합니다. 예외 처리도 잘 되어 있습니다.
|
🎉 This PR is included in version 1.8.0-develop.19 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.9.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |



✨ 개요
🧾 관련 이슈
#195
🔍 참고 사항 (선택)
Summary by CodeRabbit
릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings.