cat API의 기본 엔드 포인트는 /_cat이다. 매개 변수가 없이 호출하면 cat API에 사용할 수 있는 모든 엔드 포인트를 표시한다.



curl -XGET 'localhost:9200/_cat'

=^.^=

/_cat/allocation

/_cat/shards

/_cat/shards/{index}

/_cat/master

/_cat/nodes

/_cat/tasks

/_cat/indices

/_cat/indices/{index}

/_cat/segments

/_cat/segments/{index}

/_cat/count

/_cat/count/{index}

/_cat/recovery

/_cat/recovery/{index}

/_cat/health

/_cat/pending_tasks

/_cat/aliases

/_cat/aliases/{alias}

/_cat/thread_pool

/_cat/thread_pool/{thread_pools}

/_cat/plugins

/_cat/fielddata

/_cat/fielddata/{fields}

/_cat/nodeattrs

/_cat/repositories

/_cat/snapshots/{repository}

/_cat/templates





각각의 cap api 요약을 한다면 다음과 같다.

  • 클러스터에서 현재 실행 중인 작업
  • 세그먼트 통계
  • 세그먼트 통계(특정 인덱스로 제한)
  • 샤드 할당 - 관련 정보
  • 필드 데이터 캐시 크기
  • 개별 필드의 필드 데이터 캐시 크기
  • 복구 정보
  • 복구 정보(특정 인덱스로 제한)
  • 클러스터에 등록된 스냅샷 저장소 정보
  • 사용자 정의 노드의 속성 정보
  • 색인 통계
  • 색인 통계(특정 색인으로 제한)
  • 특정 저장소에 속한 모든 스냅샷에 대한 정보
  • 각 노드에 설치된 플러그인
  • 특정 별명의 인덱스 앨리어스와 인덱스
  • 마스터 정보(선출된 마스터 표시 포함)
  • 마스터 노드 정보
  • 클러스터 상태
  • 실행 대기 중인 작업
  • 클러스터당 노드별 쓰레드 풀 정보
  • 클러스터당 노드별 단일 또는 다중 스레드 풀에 대한 스레드 풀 정보
  • 전체 클러스터 또는 개별 인덱스의 다큐먼트 개수
  • 모든 샤드 관련 정보(특정 인덱스로 제한)


클러스터 상태 정보를 보려면 다음을 호출한다.

$ curl -XGET 'localhost:9200/_cat/health'
1496739863 18:04:23 elasticsearch yellow 1 1 60 60 0 0 41 0 - 59.4%



컬럼 내용을 보이게 하려면 v를 추가한다. 

$ curl -XGET 'localhost:9200/_cat/health?v'
epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1496740013 18:06:53  elasticsearch yellow          1         1     60  60    0    0       41             0                  -                 59.4%


help 커맨드를 사용하면 헤더 내용을 알 수 있다.


$ curl -XGET 'localhost:9200/_cat/health?help'

epoch                 | t,time                                   | seconds since 1970-01-01 00:00:00

timestamp             | ts,hms,hhmmss                            | time in HH:MM:SS

cluster               | cl                                       | cluster name

status                | st                                       | health status

node.total            | nt,nodeTotal                             | total number of nodes

node.data             | nd,nodeData                              | number of nodes that can store data

shards                | t,sh,shards.total,shardsTotal            | total number of shards

pri                   | p,shards.primary,shardsPrimary           | number of primary shards

relo                  | r,shards.relocating,shardsRelocating     | number of relocating nodes

init                  | i,shards.initializing,shardsInitializing | number of initializing nodes

unassign              | u,shards.unassigned,shardsUnassigned     | number of unassigned shards

pending_tasks         | pt,pendingTasks                          | number of pending tasks

max_task_wait_time    | mtwt,maxTaskWaitTime                     | wait time of longest task pending

active_shards_percent | asp,activeShardsPercent                  | active number of shards in percent





특정 헤더만 보고 싶다면 다음을 실행한다.


$ curl -XGET 'localhost:9200/_cat/health?h=cluster,status'

elasticsearch yellow



용량을 알아서 보여주지만, bytes=b로 하면 바이트로, bytes=mb는 메가 바이트로 표현할 수 있다.


$ curl -XGET 'localhost:9200/_cat/indices'

yellow open books               SO4qsDCoSIK2y0Hb3OcBpQ 5 1     2 0  7.4kb  7.4kb


$ curl -XGET 'localhost:9200/_cat/indices?bytes=b'

yellow open books               SO4qsDCoSIK2y0Hb3OcBpQ 5 1     2 0      7646      7646




 /_cat/master REST 엔드 포인트를 호출하면 노드에 대한 정보와 현재 노드 중 하나를 마스터로 선출할 수 있다.


$ curl -XGET 'localhost:9200/_cat/master?v'

id                     host      ip        node

5OEGj_avT8un0nOak28qQg 127.0.0.1 127.0.0.1 5OEGj_a



응답에서 알 수 있듯이 현재 어떤 노드가 마스터로 선출되었는지에 대한 정보를 얻었다. 노드의 식별자, IP 주소, 이름을 볼 수 있다.




node 정보를 확인할 수 있다.


참고로 노드 이름, 노드의 역할(노드가 마스터(m), 데이터(a), ingest(i) 또는 클라이언트(-) 노드인지 여부), 노드의 부하(load_1m, load_5m ,load_15m), 가동 시간(uptime)을 선택하려면 다음과 같이 진행할 수 있다.


(참고: https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html)


$ curl -XGET 'localhost:9200/_cat/nodes?v&h=name,node.role,load,uptime'






Posted by '김용환'
,

pretty 사용시 기본은 예쁘게 json을 볼 수 있다.


[/usr/local/elasticsearch-5.3.1/bin] curl 'localhost:9200/_cluster/health?pretty'

{

  "cluster_name" : "elasticsearch",

  "status" : "yellow",

  "timed_out" : false,

  "number_of_nodes" : 1,

  "number_of_data_nodes" : 1,

  "active_primary_shards" : 60,

  "active_shards" : 60,

  "relocating_shards" : 0,

  "initializing_shards" : 0,

  "unassigned_shards" : 41,

  "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" : 59.4059405940594

}





format=yaml 매개 변수를 사용하면 yaml 형태로 정보를 얻을 수 있다.



[/usr/local/elasticsearch-5.3.1/bin] curl 'localhost:9200/_cluster/health?pretty&format=yaml'

---

cluster_name: "elasticsearch"

status: "yellow"

timed_out: false

number_of_nodes: 1

number_of_data_nodes: 1

active_primary_shards: 60

active_shards: 60

relocating_shards: 0

initializing_shards: 0

unassigned_shards: 41

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: 59.4059405940594

Posted by '김용환'
,