Grafana

다양한 데이터 소스(Prometheus, Loki 등)에 연결해 메트릭과 로그를 시각화하는 오픈소스 대시보드 도구입니다.

핵심 특징

패널 유형

패널용도
Time seriesCPU, 메모리, 응답 시간 추이
Gauge현재 값 (CPU 사용률 72%)
Stat단일 숫자 강조 (총 요청 수)
Table다차원 데이터 테이블
Heatmap응답 시간 분포 시각화
LogsLoki 로그 스트림

Spring Boot 연동 (Prometheus + Grafana)

<!-- build.gradle -->
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
# application.yml
management:
  endpoints:
    web:
      exposure:
        include: prometheus, health
  metrics:
    tags:
      application: cslog-backend
# /actuator/prometheus 엔드포인트 노출
http_server_requests_seconds_count{method="GET",uri="/api/posts"} 1234
jvm_memory_used_bytes{area="heap"} 1.5e+08
# prometheus.yml — 스크랩 설정
scrape_configs:
  - job_name: 'cslog-backend'
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['localhost:8080']

알림 설정 흐름

Grafana Alert Rule
   └─ 쿼리 조건 평가 (예: avg(cpu) > 80)
        └─ 임계값 초과 시
             └─ Contact Point (Slack/Email) 발송

→ Grafana & Loki

CSLOG에서 보기