Boto3 for fetching the cluster health of OpenSearch domain

332 Views Asked by At

I am trying to fetch the cluster health of Opensearch domain through the boto3, but I do not find any method for the same. How to solve this problem?

1

There are 1 best solutions below

0
because_im_batman On

You do not need boto to fetch cluster health of AWS Opensearch domain. You can just make a GET request using the python requests library.

import requests
OPENSEARCH_ENDPOINT = "your_opensearch_endpoint"
res = requests.get(f'https://{OPENSEARCH_ENDPOINT}/_cluster/health')
print(res.json())

Response:

{
  "cluster_name": "<acc_id>:<opensearch_domain_name>",
  "status": "green", ## cluster health
  "timed_out": false,
  "number_of_nodes": 7,
  "number_of_data_nodes": 4,
  "discovered_master": true,
  "active_primary_shards": 3600,
  "active_shards": 7204,
  "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.0
}