我想了解使用boto3的电子病历集群的健康状况。如果它是健康的,那么我应该能够运行我的jobs.How来知道集群是否正常?我运行了下面的代码,它返回了一本字典。
import boto3
emr_client = boto3.client('emr')
clusters = emr_client.list_clusters(ClusterStates=['STARTING', 'BOOTSTRAPPING', 'RUNNING', 'WAITING'])
for cluster in clusters['Clusters']:
cluster_id = cluster['Id']
response = emr_client.list_instances(ClusterId=cluster_id)
print(response)产出:
{'Instances': [{'Id': 'ci-xxxx', 'Ec2InstanceId': 'i-xxxx', 'PublicDnsName': '', 'PrivateDnsName': 'ip-xxxx.ec2.internal', 'PrivateIpAddress': 'xxxx', 'Status': {'State': 'BOOTSTRAPPING', 'StateChangeReason': {}, 'Timeline': {'CreationDateTime': datetime.datetime(2021, 12, 27, 13, 8, 28, 758000, tzinfo=tzlocal())}}, 'InstanceGroupId': 'ig-xxxx', 'Market': 'ON_DEMAND', 'InstanceType': 'm5.xlarge', 'EbsVolumes': [{'Device': 'xxx', 'VolumeId': 'vol-xxx'}, {'Device': 'xxx', 'VolumeId': 'vol-xxxx'}]}, {'Id': 'ci-xxxx', 'Ec2InstanceId': 'i-xxxx', 'PublicDnsName': '', 'PrivateDnsName': 'ip-xxxx.ec2.internal', 'PrivateIpAddress': 'xxxx', 'Status': {'State': 'BOOTSTRAPPING', 'StateChangeReason': {}, 'Timeline': {'CreationDateTime': datetime.datetime(2021, 12, 27, 13, 8, 28, 758000, tzinfo=tzlocal())}}, 'InstanceGroupId': 'ig-xxxx', 'Market': 'ON_DEMAND', 'InstanceType': 'm5.xlarge', 'EbsVolumes': [{'Device': 'xxx', 'VolumeId': 'vol-xxxx'}, {'Device': 'xxx', 'VolumeId': 'vol-xxxx'}]}], 'ResponseMetadata': {'RequestId': 'xxxx', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'xxxx', 'content-type': 'application/x-amz-json-1.1', 'content-length': '989', 'date': 'Mon, 27 Dec 2021 19:08:55 GMT'}, 'RetryAttempts': 0}}我们如何从中获取实例状态?而list_instances是寻找EMR集群健康状况的正确方法吗?
谢谢。
https://stackoverflow.com/questions/70476295
复制相似问题