From 1ff9a59bf055d0bf175c24192f8cdaad700369a7 Mon Sep 17 00:00:00 2001 From: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Date: Wed, 18 Jan 2023 15:51:05 -0500 Subject: [PATCH] Adds cluster health by awareness attribute documentation (#2398) * Adds cluster health by awareness attribute documentation Signed-off-by: Fanit Kolchina * Added new response and edited note for clarity Signed-off-by: Fanit Kolchina * Minor rewording Signed-off-by: Fanit Kolchina * Incorporated doc review comments Signed-off-by: Fanit Kolchina * Minor edits Signed-off-by: Fanit Kolchina * More updates Signed-off-by: Fanit Kolchina * Minor rewording Signed-off-by: Fanit Kolchina * Rewording Signed-off-by: Fanit Kolchina * Minor rewording Signed-off-by: Fanit Kolchina * Update _api-reference/cluster-health.md Co-authored-by: Nate Bower * Update _api-reference/cluster-health.md Co-authored-by: Nate Bower * Removed experimental flag and reworked to add in main body Signed-off-by: Fanit Kolchina * One more merge conflict resolved Signed-off-by: Fanit Kolchina Signed-off-by: Fanit Kolchina Co-authored-by: Nate Bower --- _api-reference/cluster-health.md | 105 ++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/_api-reference/cluster-health.md b/_api-reference/cluster-health.md index 58e5c75d..eba1ca7b 100644 --- a/_api-reference/cluster-health.md +++ b/_api-reference/cluster-health.md @@ -36,7 +36,8 @@ The following table lists the available query parameters. All query parameters a Parameter | Type | Description :--- | :--- | :--- expand_wildcards | Enum | Expands wildcard expressions to concrete indexes. Combine multiple values with commas. Supported values are `all`, `open`, `closed`, `hidden`, and `none`. Default is `open`. -level | Enum | The level of detail for returned health information. Supported values are `cluster`, `indices`, and `shards`. Default is `cluster`. +level | Enum | The level of detail for returned health information. Supported values are `cluster`, `indices`, `shards`, and `awareness_attributes`. Default is `cluster`. +awareness_attribute | String | The name of the awareness attribute, for which to return cluster health (for example, `zone`). Applicable only if `level` is set to `awareness_attributes`. local | Boolean | Whether to return information from the local node only instead of from the cluster manager node. Default is false. cluster_manager_timeout | Time | The amount of time to wait for a connection to the cluster manager node. Default is 30 seconds. timeout | Time | The amount of time to wait for a response. If the timeout expires, the request fails. Default is 30 seconds. @@ -101,8 +102,106 @@ The following table lists all response fields. |number_of_in_flight_fetch | Integer | The number of unfinished fetches. | |task_max_waiting_in_queue_millis | Integer | The maximum wait time for all tasks waiting to be performed, in milliseconds. | |active_shards_percent_as_number | Double | The percentage of active shards in the cluster. | +|awareness_attributes | Object | Contains cluster health information for each awareness attribute. | + +## Returning cluster health by awareness attribute + +To check cluster health by awareness attribute (for example, zone or rack), specify `awareness_attributes` in the `level` query parameter: + +```json +GET _cluster/health?level=awareness_attributes +``` + +The response contains cluster health metrics partitioned by awareness attribute: + +```json +{ + "cluster_name": "runTask", + "status": "green", + "timed_out": false, + "number_of_nodes": 3, + "number_of_data_nodes": 3, + "discovered_master": true, + "discovered_cluster_manager": true, + "active_primary_shards": 0, + "active_shards": 0, + "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, + "awareness_attributes": { + "zone": { + "zone-3": { + "active_shards": 0, + "initializing_shards": 0, + "relocating_shards": 0, + "unassigned_shards": 0, + "data_nodes": 1, + "weight": 1 + }, + "zone-1": { + "active_shards": 0, + "initializing_shards": 0, + "relocating_shards": 0, + "unassigned_shards": 0, + "data_nodes": 1, + "weight": 1 + }, + "zone-2": { + "active_shards": 0, + "initializing_shards": 0, + "relocating_shards": 0, + "unassigned_shards": 0, + "data_nodes": 1, + "weight": 1 + } + }, + "rack": { + "rack-3": { + "active_shards": 0, + "initializing_shards": 0, + "relocating_shards": 0, + "unassigned_shards": 0, + "data_nodes": 1, + "weight": 1 + }, + "rack-1": { + "active_shards": 0, + "initializing_shards": 0, + "relocating_shards": 0, + "unassigned_shards": 0, + "data_nodes": 1, + "weight": 1 + }, + "rack-2": { + "active_shards": 0, + "initializing_shards": 0, + "relocating_shards": 0, + "unassigned_shards": 0, + "data_nodes": 1, + "weight": 1 + } + } + } +} +``` + +If you're interested in a particular awareness attribute, you can include the name of the awareness attribute as a query parameter: + +```json +GET _cluster/health?level=awareness_attributes&awareness_attribute=zone +``` + +In response to the preceding request, OpenSearch returns cluster health information only for the `zone` awareness attribute. + +The unassigned shard information will be accurate only if you [enable replica count enforcement]({{site.url}}{{site.baseurl}}/opensearch/cluster#forced-replica-count-enforcement) and [configure forced awareness]({{site.url}}{{site.baseurl}}/opensearch/cluster#forced-awareness) for the awareness attribute either before cluster start or after cluster start but before any indexing requests. If you enable replica enforcement after the cluster receives indexing requests, the unassigned shard information may be inaccurate. If you don't configure replica count enforcement and forced awareness, the `unassigned_shards` field will contain -1. +{: .warning} ## Required permissions -If you use the security plugin, make sure you have the appropriate permissions: -`cluster:monitor/health`. \ No newline at end of file +If you use the Security plugin, make sure you have the appropriate permissions: +`cluster:monitor/health`.