본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Cluster State API

원문 보기 위키 갱신

/_cluster/state API는 클러스터의 현재 상태를 검색해요. 여기에는 메타데이터, 라우팅 테이블, 노드, 기타 구성 요소가 포함돼요. 이 API는 주로 모니터링, 디버깅, 내부 목적으로 사용돼요. 클러스터 매니저 노드가 유지 관리하는 클러스터 상태의 여러 부분에 대한 스냅샷을 제공해요.

출처: OpenSearch 문서

본문

엔드포인트 (Endpoints)

GET /_cluster/state
GET /_cluster/state/{metric}
GET /_cluster/state/{metric}/{target}

경로 매개변수 (Path parameters)

다음 표는 사용할 수 있는 경로 매개변수를 나열한 것이에요. 모든 경로 매개변수는 선택 사항이에요.

| Parameter | Data type | Description | | metric | String or List | A comma-separated list of metrics to include in the response. See Metric options for a list of available options. Default is _all. | | target | String or List | A comma-separated list of index names, data streams, and index aliases used to limit the scope of the response. |

메트릭 옵션 (Metric options)

metric 경로 매개변수를 사용해 API가 반환하는 정보를 제한할 수 있어요. 사용할 수 있는 옵션은 다음과 같아요.

  • _all (기본값): 모든 메트릭을 반환해요.
  • blocks: 인덱스 레벨 및 전역 블록에 대한 정보를 포함해요.
  • metadata: 인덱스 설정, 매핑, 템플릿을 포함한 클러스터 메타데이터를 반환해요.
  • nodes: 클러스터 안의 노드 정보를 반환해요.
  • routing_table: 모든 샤드에 대한 라우팅 정보를 제공해요.
  • cluster_manager_node: 현재 선출된 클러스터 매니저 노드의 ID를 표시해요.
  • version: 현재 클러스터 상태 버전을 표시해요.

쿼리 매개변수 (Query parameters)

다음 표는 사용할 수 있는 쿼리 매개변수를 나열한 것이에요. 모든 쿼리 매개변수는 선택 사항이에요.

| Parameter | Data type | Description | | local | Boolean | If true, retrieves the state from the local node instead of the cluster manager node. Default is false. | | cluster_manager_timeout | Time | The timeout duration for connecting to the cluster manager node. Default is 30s. | | flat_settings | Boolean | If true, returns settings in a flat format. Default is false. | | wait_for_metadata_version | Integer | Waits until the metadata version is equal to or greater than this value before responding. | | wait_for_timeout | Time | Specifies how long to wait when using wait_for_metadata_version. Default is 30s. | | ignore_unavailable | Boolean | Whether to ignore missing or closed indexes. Default is false. | | expand_wildcards | String | Specifies the type of index that wildcard expressions can match. Supports comma-separated values. Valid values are: - all: Match any index, including hidden ones. - closed: Match closed, non-hidden indexes. - hidden: Match hidden indexes. Must be combined with open, closed, or both. - none: Wildcard expressions are not accepted. - open: Match open, non-hidden indexes. Default is open. | | allow_no_indices | Boolean | Whether to fail if a wildcard expression or index alias resolves to no indexes. Default is true. |

예제 요청 (Example requests)

전체 클러스터 상태를 검색해요.

GET /_cluster/state
response = client.cluster.state()

특정 인덱스의 메타데이터와 라우팅 테이블을 검색해요.

GET /_cluster/state/metadata,routing_table/my-index
response = client.cluster.state(
metric = "metadata,routing_table",
index = "my-index"
)

현재 선출된 클러스터 매니저 노드만 검색해요.

GET /_cluster/state/cluster_manager_node
response = client.cluster.state(
metric = "cluster_manager_node"
)

응답 필드 (Response fields)

다음 표는 모든 응답 필드를 나열한 것이에요.

| Field | Data type | Description | | cluster_name | String | The name of the cluster. | | cluster_uuid | String | The unique identifier for the cluster. | | version | Integer | The current version of the cluster state. | | state_uuid | String | The unique identifier for this version of the state. | | master_node | String | As with cluster_manager_node, this is maintained for backward compatibility. | | cluster_manager_node | String | The node ID of the elected cluster manager node. | | blocks | Object | Index-level block settings. | | metadata | Object | Index mappings, settings, and aliases. | | nodes | Object | Details of all nodes in the cluster. | | routing_table | Object | Shard-to-node allocation per index. | | routing_nodes | Object | Lists of shards assigned to each node. | | indices | Object | Index-specific state metadata. |

필요한 권한 (Required permissions)

Security 플러그인을 사용한다면 적절한 권한을 확인하세요: cluster:monitor/state

더 알아보기 (Learn more)