C
DevOps/클라우드_관측/Lesson 04

클라우드 + 모니터링 — AWS·Prometheus·Grafana

45분·theory

클라우드 + 모니터링 — AWS·Prometheus·Grafana

🎯 이 lesson 을 읽고 나면

이 lesson 을 다 읽고 나면 아래 3가지를 자신 있게 할 수 있습니다.

  • ✅ AWS / GCP / Azure 핵심 서비스 매핑
  • ✅ OpenTelemetry (Trace · Metrics · Logs) 셋업
  • ✅ SLO/SLI/SLA + Prometheus + Grafana

학습 목표를 체크리스트로 두고 다 답할 수 있게 되면 lesson 을 닫으세요.

AWS 주요 서비스 + 클라우드 선택

AWS (시장 1위, 2006~):

카테고리서비스
컴퓨트EC2 (VM) · Lambda (서버리스) · ECS·EKS (컨테이너)
저장S3 (객체) · EBS (블록) · EFS (파일)
DBRDS (관리형 RDBMS) · DynamoDB (NoSQL) · ElastiCache (Redis)
네트워크VPC · CloudFront (CDN) · Route 53 (DNS) · API Gateway
DevOpsCodeDeploy · CodePipeline · CloudFormation
보안IAM · KMS · Secrets Manager · WAF
관측CloudWatch · X-Ray (트레이싱)

클라우드 비교:

클라우드강점한국 시장
AWS가장 다양 · 학습 자료1위
GCPKubernetes·AI 강력증가
Azure엔터프라이즈·Microsoft 생태기업
Naver Cloud한국 데이터·인증정부·금융

비용 절감 팁:

  • Reserved Instance / Savings Plan — 1·3년 약정 (~60% 할인)
  • Spot Instance — 중단 가능 (~90% 할인) · 배치 작업
  • S3 Glacier — 옛 데이터 (~$0.004/GB)
  • Auto Scaling — 트래픽에 맞춰 자동
  • CloudWatch Billing Alarm — 임계 초과 시 알람

관측성 — Metrics · Logs · Traces

3 축 관측성:

무엇도구
Metrics시계열 수치 (CPU·요청수·에러율)Prometheus + Grafana / Datadog / CloudWatch
Logs텍스트 이벤트Loki / ELK (Elasticsearch+Kibana) / Datadog
Traces분산 호출 추적Jaeger / Tempo / Datadog APM

Prometheus + Grafana (오픈소스 표준):

  • Prometheus = 메트릭 수집·저장 (pull 방식)
  • Grafana = 시각화 (대시보드)
  • Alertmanager = 알람 (Slack·PagerDuty)

4 골든 시그널 (구글 SRE):
1. Latency — 응답 시간 (p50·p95·p99)
2. Traffic — 요청 수 (QPS)
3. Errors — 5xx·예외율
4. Saturation — CPU·메모리·디스크·DB 연결

SLO·SLI·SLA:

  • SLI (Indicator) — 측정 가능 지표 (예: 가용성 %)
  • SLO (Objective) — 목표 (예: 99.9% 가용)
  • SLA (Agreement) — 계약 (위반 시 보상)
  • Error Budget — 100% - SLO. 0.1% = 월 43분 다운 OK

eBPF 기반 도구 (2024+ 트렌드):

  • Cilium (네트워크), Falco (보안), Pixie (앱 관측)
  • 커널 안에서 안전하게 코드 실행 → 코드 수정 X
💻 📌 Prometheus + Grafana 예시
# ============================================
# docker-compose.yml — 로컬 Prometheus + Grafana
# ============================================
version: '3'
services:
  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    ports: ["9090:9090"]

  grafana:
    image: grafana/grafana:latest
    ports: ["3001:3000"]
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=admin
    volumes:
      - grafana-data:/var/lib/grafana

  node-exporter:                # 시스템 메트릭
    image: prom/node-exporter:latest
    ports: ["9100:9100"]

volumes:
  grafana-data:

# ============================================
# prometheus.yml — 메트릭 수집 설정
# ============================================
# global:
#   scrape_interval: 15s
# scrape_configs:
#   - job_name: 'myapp'
#     static_configs:
#       - targets: ['localhost:3000']      # /metrics 엔드포인트
#   - job_name: 'node'
#     static_configs:
#       - targets: ['node-exporter:9100']

# ============================================
# Node.js 앱에 메트릭 노출
# ============================================
# const express = require('express');
# const { register, Counter, Histogram } = require('prom-client');
# const app = express();
#
# const httpRequests = new Counter({
#   name: 'http_requests_total',
#   help: 'Total HTTP requests',
#   labelNames: ['method', 'route', 'status']
# });
#
# const httpDuration = new Histogram({
#   name: 'http_duration_seconds',
#   help: 'HTTP request duration',
#   labelNames: ['method', 'route'],
#   buckets: [0.01, 0.05, 0.1, 0.5, 1, 5]
# });
#
# app.use((req, res, next) => {
#   const end = httpDuration.startTimer({ method: req.method, route: req.path });
#   res.on('finish', () => {
#     httpRequests.inc({ method: req.method, route: req.path, status: res.statusCode });
#     end();
#   });
#   next();
# });
#
# app.get('/metrics', async (req, res) => {
#   res.set('Content-Type', register.contentType);
#   res.end(await register.metrics());
# });

🤖 AI 에게 이렇게 요청해보세요

이 lesson 의 개념을 알면 AI 에게 구체적으로 지시할 수 있습니다. 막연한 "고쳐줘" 가 아니라 어휘를 가진 요청 — 그게 토큰 절약의 출발점입니다.

  • "이 앱에 OpenTelemetry trace + metrics + logs 셋업해줘"
  • "이 SLO (가용성 99.9%) 모니터링을 Prometheus + Grafana 로 구성해줘"

왜 이게 토큰을 줄이나

개념을 모를 땐 AI 답변을 받고도 "그게 뭐예요?" 를 다시 물어야 합니다. 그 "다시 물음" 이 토큰을 잡아먹습니다. 개념 한 번 익혀두면 대화가 한 번에 끝납니다.

다음 추천: 협업 & Git