Spring/Spring Boot

[Spring Boot][Actuator] 1. 모니터링

noahkim_ 2025. 9. 5. 08:11

1. 상태

Health

  • 애플리케이션의 전반적인 헬스 상태를 제공함
  • ✅ 현재 애플리케이션이 정상 동작하는지, 아니면 오류가 있는지 알려줌 (UP/DOWN/OUT_OF_SERVICE)
  • path: "/actuator/health"
Path 설명 예시 / 특징
status
애플리케이션 전체 상태
예: UP, DOWN
details
애플리케이션 세부 상태 정보
management.endpoint.health.show-details 값에 해당하는 정보 출력
details.*.status
특정 컴포넌트의 상태
예: DB, 디스크, MQ 등
details.*.details
해당 컴포넌트의 추가 정보
예: 남은 디스크 용량, DB 연결 여부 등

 

설정) application.yml

더보기
management:
  endpoints.web.exposure.include: health
  endpoint:
    health:
      show-details: always
      show-components: always
  • management.endpoint.health.show-details: 상세 출력
  • management.endpoint.health.show-components: 각 컴포넌트별 항목도 함께 표시

 

예시) 응답

더보기
{
  "status" : "UP",
  "details" : {
    "diskSpaceHealthIndicator" : {
      "status" : "UP",
      "details" : {
        "total" : 162350022656,
        "free" : 29866389504,
        "threshold" : 10485760
      }
    },
    "dataSourceHealthIndicator" : {
      "status" : "UP",
      "details" : {
        "database" : "HSQL Database Engine",
        "hello" : 1
      }
    }
  }
}

 

Info

  • 애플리케이션의 일반 정보를 제공하는 엔드포인트
  • InfoContributor들이 제공한 섹션들이 합쳐져 JSON으로 반환됨 (build, git 등)
  •  build 섹션: JAR 안에 META-INF/build-info.properties가 있어야 해요.
  • ✅ path: "/actuator/info"

 

설정) application.yml

더보기
management:
  endpoints:
    web:
      exposure:
        include: info    # /actuator/info 노출
  endpoint:
    info:
      enabled: true     # (기본 true) 비활성화하려면 false

 

설정) build section (gradle)

더보기
springBoot {
    buildInfo()
}
  • bootBuildInfo task를 실행하면 build/resource에 META-INF에 build-info.properties 파일이 생성됨
  • build-info.properties은 해당 프로젝트의 빌드 정보를 담고있음
  • build 섹션의 본문으로 사용됨

 

예시) 응답

더보기
{
  "build": {
    "artifact": "chat",
    "name": "chat",
    "time": "2025-09-05T02:24:22.504Z",
    "version": "1.0-SNAPSHOT",
    "group": "org.example"
  },
  "grpc.server": {
    "port": 18080,
    "services": {
      "chatmessage.v1.ChatMessageGrpcService": [
        "save"
      ],
      "grpc.health.v1.Health": [
        "Check",
        "Watch"
      ],
      "grpc.reflection.v1alpha.ServerReflection": [
        "ServerReflectionInfo"
      ]
    }
  }
}

 

2. 메트릭

Metrics

  • 애플리케이션이 현재 기록하고 있는 메트릭을 확인할 수 있는 Actuator endpoint
  • 태그 기반 drill-down (tag=name:value 형태로 세부 값 조회) 
  • ✅ /actuator/metrics, /actuator/metrics/{metric.name}
항목 설명
name 메트릭 이름
description 메트릭 설명
baseUnit 기본 단위
measurements 실제 측정값 목록
measurements[].statistic 측정값 종류 (VALUE, COUNT, TOTAL 등)
measurements[].value 실제 숫자 값
availableTags drill-down 가능한 태그 목록

 

Prometheus

  • prometheus 서버가 수집할 수 있는 형식으로 변환해서 제공하는 endpoint
  • openmetrics 지원
  • ✅ /actuator/prometheus
요소 설명
# HELP 메트릭 설명
# TYPE 메트릭 타입 (gauge, counter 등)
sample line 메트릭 이름 + label + 값

 

예시) prometheus 응답

더보기
# HELP jvm_memory_used_bytes The amount of used memory
# TYPE jvm_memory_used_bytes gauge
jvm_memory_used_bytes{area="heap",id="G1 Eden Space"} 5.3477376E7

 

출처