Elasticsearch 모니터링 및 장애 판단 지표

개요

Elasticsearch 클러스터의 상태를 모니터링하고 장애를 판단하기 위한 API와 지표를 정리한 문서입니다.


1. 클러스터 상태 (가장 중요)

API

GET /_cluster/health

응답 예시

{
  "cluster_name": "my-cluster",
  "status": "green",
  "timed_out": false,
  "number_of_nodes": 3,
  "number_of_data_nodes": 3,
  "active_primary_shards": 50,
  "active_shards": 100,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 0,
  "delayed_unassigned_shards": 0,
  "number_of_pending_tasks": 0,
  "number_of_in_flight_fetch": 0,
  "task_max_waiting_in_queue_millis": 0,
  "active_shards_percent_as_number": 100.0
}

장애 판단 기준

상태의미장애 여부조치
green모든 샤드 정상정상-
yellow프라이머리 OK, 레플리카 문제주의레플리카 샤드 확인
red프라이머리 샤드 유실장애즉시 조치 필요

주요 체크 항목

필드장애 기준
statusred
unassigned_shards> 0
number_of_pending_tasks지속적으로 증가

2. 노드 상태

API

# 노드 목록 및 리소스 사용량
GET /_cat/nodes?v&h=name,ip,heap.percent,ram.percent,cpu,load_1m,node.role,master

# 노드 상세 통계
GET /_nodes/stats

장애 판단 기준

지표정상주의장애
노드 수예상과 동일-예상보다 적음
heap.percent< 75%75-85%> 85%
cpu< 70%70-90%> 90% 지속
load_1m< 코어 수코어 수 근접> 코어 수 * 2

3. Thread Pool (핵심 지표)

API

# write, search thread pool 상태
GET /_cat/thread_pool/write,search?v&h=node_name,name,active,queue,rejected

# 전체 thread pool
GET /_cat/thread_pool?v

응답 예시

node_name  name   active queue rejected
node-1     write  5      0     0
node-1     search 10     0     0
node-2     write  3      0     0
node-2     search 8      0     0

장애 판단 기준

지표정상주의장애
rejected0-> 0 (요청 유실)
queue0증가 추세지속적 증가
active-최대치 근접최대치 지속

Thread Pool 종류

이름용도
write인덱싱, 업데이트, 삭제, 벌크 요청
search검색 요청
get실시간 GET 요청
analyze분석 요청

4. JVM 메모리

API

# JVM 메모리 상태
GET /_nodes/stats/jvm

# 간단한 힙 사용량
GET /_cat/nodes?v&h=name,heap.percent,heap.current,heap.max

장애 판단 기준

지표정상주의장애
heap_used_percent< 75%75-85%> 85%
Old GC 빈도낮음증가빈번 (STW 발생)
Old GC 시간< 1초1-5초> 5초

GC 관련 확인

GET /_nodes/stats/jvm?filter_path=nodes.*.jvm.gc

5. 디스크 사용량

API

# 노드별 디스크 사용량
GET /_cat/allocation?v&h=node,disk.percent,disk.used,disk.avail,disk.total

# 샤드별 디스크 사용량
GET /_cat/shards?v&h=index,shard,store

장애 판단 기준 (워터마크)

디스크 사용률상태ES 동작
< 85%정상-
85% (low)주의새 샤드 할당 중지
90% (high)위험샤드 재배치 시작
95% (flood)장애인덱싱 차단 (읽기 전용)

워터마크 설정 확인

GET /_cluster/settings?include_defaults=true&filter_path=*.cluster.routing.allocation.disk

6. 샤드 상태

API

# 샤드 상태 확인
GET /_cat/shards?v&h=index,shard,prirep,state,unassigned.reason

# UNASSIGNED 샤드만 확인
GET /_cat/shards?v&h=index,shard,prirep,state,unassigned.reason&s=state

# 샤드 할당 설명
GET /_cluster/allocation/explain

샤드 상태 종류

상태의미조치
STARTED정상 동작-
RELOCATING다른 노드로 이동 중대기
INITIALIZING초기화 중대기
UNASSIGNED할당 안 됨원인 파악 필요

UNASSIGNED 원인

원인설명
INDEX_CREATED인덱스 생성 직후
CLUSTER_RECOVERED클러스터 복구 중
NODE_LEFT노드 이탈
ALLOCATION_FAILED할당 실패
NO_VALID_SHARD_COPY유효한 샤드 복사본 없음

7. 인덱싱/검색 성능

API

# 인덱싱/검색 통계
GET /_stats/indexing,search

# 특정 인덱스
GET /my-index/_stats/indexing,search

주요 지표

지표설명장애 기준
indexing.index_total총 인덱싱 수-
indexing.index_failed인덱싱 실패 수> 0
indexing.index_time_in_millis인덱싱 소요 시간급증 시 주의
search.query_total총 검색 수-
search.query_time_in_millis검색 소요 시간평소 대비 급증

8. 펜딩 태스크

API

# 대기 중인 클러스터 태스크
GET /_cluster/pending_tasks

# 실행 중인 태스크
GET /_tasks

장애 판단 기준

지표정상주의장애
펜딩 태스크 수0일시적 증가지속적 증가
time_in_queue_millis< 10001000-5000> 5000

장애 판단 체크리스트 (우선순위)

순위지표API장애 기준심각도
1클러스터 상태/_cluster/healthstatus: redCritical
2Thread Pool Rejected/_cat/thread_pool/write?vrejected > 0Critical
3힙 메모리/_cat/nodes?h=heap.percent> 90%High
4디스크 사용량/_cat/allocation?v> 90%High
5Unassigned 샤드/_cluster/healthunassigned_shards > 0High
6노드 수/_cat/nodes예상보다 적음High
7인덱싱 실패/_stats/indexingindex_failed > 0Medium
8펜딩 태스크/_cluster/pending_tasks지속적 증가Medium

모니터링 주기 권장

지표주기
클러스터 상태10초
Thread Pool Rejected10초
노드 상태30초
힙 메모리30초
디스크 사용량1분
인덱싱/검색 통계1분

Kibana Dev Tools용 쿼리 모음

# ========================================
# 클러스터 상태
# ========================================

# 클러스터 전체 상태
GET /_cluster/health

# 인덱스별 상태
GET /_cluster/health?level=indices

# ========================================
# 노드 상태
# ========================================

# 노드 리소스 사용량
GET /_cat/nodes?v&h=name,ip,heap.percent,ram.percent,cpu,load_1m,node.role,master

# ========================================
# Thread Pool (rejected 확인)
# ========================================

# write/search thread pool
GET /_cat/thread_pool/write,search?v&h=node_name,name,active,queue,rejected

# ========================================
# 디스크 사용량
# ========================================

# 노드별 디스크
GET /_cat/allocation?v&h=node,disk.percent,disk.avail

# ========================================
# 샤드 상태
# ========================================

# 전체 샤드
GET /_cat/shards?v&s=state

# UNASSIGNED 원인
GET /_cluster/allocation/explain

# ========================================
# 성능 통계
# ========================================

# 인덱싱/검색 통계
GET /_stats/indexing,search?filter_path=_all.total

# ========================================
# 펜딩 태스크
# ========================================

GET /_cluster/pending_tasks

참고