群集API用于獲取有關(guān)群集及其節(jié)點(diǎn)的信息并在其中進(jìn)行更改。要調(diào)用此API,我們需要指定節(jié)點(diǎn)名稱(chēng),地址或_local。
GET /_nodes/_local
運(yùn)行上面的代碼后,我們得到如下所示的響應(yīng):
……………………………………………… 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用于通過(guò)附加'health'關(guān)鍵字來(lái)獲取集群運(yùn)行狀況的狀態(tài)。
GET /_cluster/health
運(yùn)行上面的代碼后,我們得到如下所示的響應(yīng):
{ "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用于通過(guò)附加'state'關(guān)鍵字URL來(lái)獲取有關(guān)集群的狀態(tài)信息。狀態(tài)信息包含版本,主節(jié)點(diǎn),其他節(jié)點(diǎn),路由表,元數(shù)據(jù)和塊。
GET /_cluster/state
運(yùn)行上面的代碼后,我們得到如下所示的響應(yīng):
……………………………………………… { "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通過(guò)使用'stats'關(guān)鍵字來(lái)幫助檢索有關(guān)群集的統(tǒng)計(jì)信息。該API返回分片號(hào),存儲(chǔ)大小,內(nèi)存使用率,節(jié)點(diǎn)數(shù),角色,操作系統(tǒng)和文件系統(tǒng)。
GET /_cluster/stats
運(yùn)行上面的代碼后,我們得到如下所示的響應(yīng):
…………………………………………. "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,您可以使用“設(shè)置”關(guān)鍵字來(lái)更新集群的設(shè)置。有兩種類(lèi)型的設(shè)置-持久性(在重新啟動(dòng)中應(yīng)用)和瞬態(tài)(在完整的集群重新啟動(dòng)后無(wú)法生存)。
該API用于檢索集群中另外一個(gè)節(jié)點(diǎn)的統(tǒng)計(jì)信息。節(jié)點(diǎn)統(tǒng)計(jì)信息與集群幾乎相同。
GET /_nodes/stats
運(yùn)行上面的代碼后,我們得到如下所示的響應(yīng):
{ "_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" }, ………………………………………………………….
該API可幫助您檢索有關(guān)群集中每個(gè)節(jié)點(diǎn)上的當(dāng)前熱線程的信息。
GET /_nodes/hot_threads
運(yùn)行上面的代碼后,我們得到如下所示的響應(yīng):
:::{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: