Complete the code to check the cluster health status.
GET /_cluster/health?wait_for_status=[1]The wait_for_status parameter waits until the cluster reaches the green status, which means all primary and replica shards are active, ensuring reliability.
Complete the code to retrieve the number of active primary shards.
GET /_cluster/health?filter_path=[1]status or number_of_nodes fields.The active_primary_shards field shows how many primary shards are active, which is important for data reliability.
Fix the error in the code to wait for the cluster to be at least yellow.
GET /_cluster/health?wait_for_status=[1]Waiting for yellow status ensures all primary shards are active, which is a minimum for reliability, even if some replicas are not allocated.
Fill both blanks to filter the cluster health response to only show status and number of nodes.
GET /_cluster/health?filter_path=[1],[2]
The filter_path parameter limits the response to only the status and number_of_nodes fields, helping focus on cluster health and size.
Fill all three blanks to create a dictionary comprehension that maps node names to their roles if the cluster status is green.
nodes_roles = {node['name']: node['roles'] for node in cluster['nodes'] if cluster['status'] == [1] and 'data' [2] node['roles'] and 'master' [3] node['roles']}This comprehension selects nodes only if the cluster is green and the node has both 'data' and 'master' roles, ensuring reliability by focusing on active nodes.