简体   繁体   中英

Health & Status of EMR Cluster using Boto3

I want to get the health status of EMR Cluster using Boto3. If it is healthy,then I should be able to run my jobs. Using the below script I am able to fetch Cluster Id but how to know if the cluster is healthy?

import boto3
import psycopg2

emr_client = boto3.client('emr')
clusters = emr_client.list_clusters(ClusterStates=['BOOTSTRAPPING', 'RUNNING', 'WAITING'])

for cluster in clusters['Clusters']:
  cluster_id = cluster['Id']
  response = emr_client.describe_cluster(ClusterId=cluster_id)
  cluster_arn = response['Cluster']['ClusterArn']
  cluster_dns_name = response['Cluster']['MasterPublicDnsName']  
  print("Active Cluster Id = "+cluster_id+",Arn = "+cluster_arn+",DNS = "+cluster_dns_name)

Thanks.

I guess that what you want is health of instances in the cluster. If so you have to list_instances , and there you can find their Status . You can also iterate over the instance ids from the previous command and use describe_instance_status for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM