Elasticsearch-cluster-apis

提供:Dev Guides
移動先:案内検索

Elasticsearch-クラスターAPI

クラスターAPIは、クラスターとそのノードに関する情報を取得し、それらを変更するために使用されます。 このAPIを呼び出すには、ノード名、アドレス、または_localを指定する必要があります。

GET/_nodes/_local

上記のコードを実行すると、次のように応答が得られます-

………………………………………………
cluster_name" : "elasticsearch",
   "nodes" : {
      "FKH-5blYTJmff2rJ_lQOCg" : {
         "name" : "ubuntu",
         "transport_address" : "127.0.0.1:9300",
         "host" : "127.0.0.1",
         "ip" : "127.0.0.1",
         "version" : "7.0.0",
         "build_flavor" : "default",
         "build_type" : "tar",
         "build_hash" : "b7e28a7",
         "total_indexing_buffer" : 106502553,
         "roles" : [
            "master",
            "data",
            "ingest"
         ],
         "attributes" : {
………………………………………………

クラスターの健全性

このAPIは、「health」キーワードを追加することにより、クラスターの状態に関するステータスを取得するために使用されます。

GET/_cluster/health

上記のコードを実行すると、次のように応答が得られます-

{
   "cluster_name" : "elasticsearch",
   "status" : "yellow",
   "timed_out" : false,
   "number_of_nodes" : 1,
   "number_of_data_nodes" : 1,
   "active_primary_shards" : 7,
   "active_shards" : 7,
   "relocating_shards" : 0,
   "initializing_shards" : 0,
   "unassigned_shards" : 4,
   "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" : 63.63636363636363
}

クラスター状態

このAPIは、「状態」キーワードURLを追加することにより、クラスターに関する状態情報を取得するために使用されます。 状態情報には、バージョン、マスターノード、他のノード、ルーティングテーブル、メタデータ、ブロックが含まれます。

GET/_cluster/state

上記のコードを実行すると、次のように応答が得られます-

………………………………………………
{
   "cluster_name" : "elasticsearch",
   "cluster_uuid" : "IzKu0OoVTQ6LxqONJnN2eQ",
   "version" : 89,
   "state_uuid" : "y3BlwvspR1eUQBTo0aBjig",
   "master_node" : "FKH-5blYTJmff2rJ_lQOCg",
   "blocks" : { },
   "nodes" : {
      "FKH-5blYTJmff2rJ_lQOCg" : {
      "name" : "ubuntu",
      "ephemeral_id" : "426kTGpITGixhEzaM-5Qyg",
      "transport
   }
………………………………………………

クラスター統計

このAPIは、「stats」キーワードを使用してクラスターに関する統計を取得するのに役立ちます。 このAPIは、シャード番号、ストアサイズ、メモリ使用量、ノード数、ロール、OS、およびファイルシステムを返します。

GET/_cluster/stats

上記のコードを実行すると、次のように応答が得られます-

………………………………………….
"cluster_name" : "elasticsearch",
"cluster_uuid" : "IzKu0OoVTQ6LxqONJnN2eQ",
"timestamp" : 1556435464704,
"status" : "yellow",
"indices" : {
   "count" : 7,
   "shards" : {
      "total" : 7,
      "primaries" : 7,
      "replication" : 0.0,
      "index" : {
         "shards" : {
         "min" : 1,
         "max" : 1,
         "avg" : 1.0
      },
      "primaries" : {
         "min" : 1,
         "max" : 1,
         "avg" : 1.0
      },
      "replication" : {
         "min" : 0.0,
         "max" : 0.0,
         "avg" : 0.0
      }
………………………………………….

クラスタ更新設定

このAPIを使用すると、「settings」キーワードを使用してクラスターの設定を更新できます。 設定には2つのタイプがあります-永続的(再起動全体に適用)と一時的(完全なクラスタ再起動に耐えられない)。

ノード統計

このAPIは、クラスターのもう1つのノードの統計を取得するために使用されます。 ノードの統計は、クラスターとほぼ同じです。

GET/_nodes/stats

上記のコードを実行すると、次のように応答が得られます-

{
   "_nodes" : {
      "total" : 1,
      "successful" : 1,
      "failed" : 0
   },
   "cluster_name" : "elasticsearch",
   "nodes" : {
      "FKH-5blYTJmff2rJ_lQOCg" : {
         "timestamp" : 1556437348653,
         "name" : "ubuntu",
         "transport_address" : "127.0.0.1:9300",
         "host" : "127.0.0.1",
         "ip" : "127.0.0.1:9300",
         "roles" : [
            "master",
            "data",
            "ingest"
         ],
         "attributes" : {
            "ml.machine_memory" : "4112797696",
            "xpack.installed" : "true",
            "ml.max_open_jobs" : "20"
         },
………………………………………………………….

ノードhot_threads

このAPIは、クラスター内の各ノードの現在のホットスレッドに関する情報を取得するのに役立ちます。

GET/_nodes/hot_threads

上記のコードを実行すると、次のように応答が得られます-

:::{ubuntu}{FKH-5blYTJmff2rJ_lQOCg}{426kTGpITGixhEzaM5Qyg}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=4112797696,
xpack.installed=true, ml.max_open_jobs=20}
 Hot threads at 2019-04-28T07:43:58.265Z, interval=500ms, busiestThreads=3,
ignoreIdleThreads=true: