There are more AWS SDK examples available in the AWS Doc SDK Examples
Use DescribeCluster with an AWS SDK or CLI
The following code examples show how to use DescribeCluster.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:
- CLI
-
- AWS CLI
-
To describe a cluster
The following
describe-clusterexample describes the specified cluster.aws emr describe-cluster \ --cluster-idj-XXXXXXXXFor a release-label based uniform instance groups cluster, the output looks like the following.
Output:
{ "Cluster": { "Status": { "Timeline": { "ReadyDateTime": "2015-07-09T16:51:15.199000-0400", "CreationDateTime": "2015-07-09T16:44:16.563000-0400" }, "State": "WAITING", "StateChangeReason": { "Message": "Waiting for steps to run" } }, "Ec2InstanceAttributes": { "ServiceAccessSecurityGroup": "sg-xxxxxxxx", "EmrManagedMasterSecurityGroup": "sg-xxxxxxxx", "IamInstanceProfile": "EMR_EC2_DefaultRole", "Ec2KeyName": "myKey", "Ec2AvailabilityZone": "us-west-2c", "EmrManagedSlaveSecurityGroup": "sg-yyyyyyyyy" }, "Name": "My Cluster", "ServiceRole": "EMR_DefaultRole", "Tags": [], "TerminationProtected": true, "UnhealthyNodeReplacement": true, "ReleaseLabel": "emr-4.0.0", "NormalizedInstanceHours": 96, "InstanceGroups": [ { "RequestedInstanceCount": 2, "Status": { "Timeline": { "ReadyDateTime": "2015-07-09T16:51:14.245000-0400", "CreationDateTime": "2015-07-09T16:44:16.564000-0400", "EndDateTime": "2015-07-11T14:09:18.387000-0400" }, "State": "RUNNING", "StateChangeReason": { "Message": "" } }, "Name": "CORE", "InstanceGroupType": "CORE", "Id": "ig-YYYYYYY", "Configurations": [], "InstanceType": "m3.large", "Market": "ON_DEMAND", "RunningInstanceCount": 2 }, { "RequestedInstanceCount": 1, "Status": { "Timeline": { "ReadyDateTime": "2015-07-09T16:51:14.245000-0400", "CreationDateTime": "2015-07-09T16:44:16.564000-0400", "EndDateTime": "2015-07-11T14:09:18.387000-0400" }, "State": "RUNNING", "StateChangeReason": { "Message": "" } }, "Name": "MASTER", "InstanceGroupType": "MASTER", "Id": "ig-XXXXXXXXX", "Configurations": [], "InstanceType": "m3.large", "Market": "ON_DEMAND", "RunningInstanceCount": 1 } ], "Applications": [ { "Name": "Hadoop" } ], "VisibleToAllUsers": true, "BootstrapActions": [], "MasterPublicDnsName": "ec2-54-147-144-78.compute-1.amazonaws.com", "AutoTerminate": false, "Id": "j-XXXXXXXX", "Configurations": [ { "Properties": { "fs.s3.consistent.retryPeriodSeconds": "20", "fs.s3.enableServerSideEncryption": "true", "fs.s3.consistent": "false", "fs.s3.consistent.retryCount": "2" }, "Classification": "emrfs-site" } ] } }For a release-label based instance fleet cluster, the output looks like the following.
Output:
{ "Cluster": { "Status": { "Timeline": { "ReadyDateTime": "2017-02-23T19:48:09.705000-0500", "CreationDateTime": "2017-02-23T19:42:13.942000-0500" }, "State": "WAITING", "StateChangeReason": { "Message": "Waiting for steps to run" } }, "Ec2InstanceAttributes": { "EmrManagedMasterSecurityGroup": "sg-xxxxx", "RequestedEc2AvailabilityZones": [], "RequestedEc2SubnetIds": [], "IamInstanceProfile": "EMR_EC2_DefaultRole", "Ec2AvailabilityZone": "us-west-2a", "EmrManagedSlaveSecurityGroup": "sg-xxxxx" }, "Name": "My Cluster", "ServiceRole": "EMR_DefaultRole", "Tags": [], "TerminationProtected": false, "UnhealthyNodeReplacement": false, "ReleaseLabel": "emr-5.2.0", "NormalizedInstanceHours": 472, "InstanceCollectionType": "INSTANCE_FLEET", "InstanceFleets": [ { "Status": { "Timeline": { "ReadyDateTime": "2017-02-23T19:46:52.740000-0500", "CreationDateTime": "2017-02-23T19:42:13.948000-0500" }, "State": "RUNNING", "StateChangeReason": { "Message": "" } }, "ProvisionedSpotCapacity": 1, "Name": "MASTER", "InstanceFleetType": "MASTER", "LaunchSpecifications": { "SpotSpecification": { "TimeoutDurationMinutes": 60, "TimeoutAction": "TERMINATE_CLUSTER" } }, "TargetSpotCapacity": 1, "ProvisionedOnDemandCapacity": 0, "InstanceTypeSpecifications": [ { "BidPrice": "0.5", "InstanceType": "m3.xlarge", "WeightedCapacity": 1 } ], "Id": "if-xxxxxxx", "TargetOnDemandCapacity": 0 } ], "Applications": [ { "Version": "2.7.3", "Name": "Hadoop" } ], "ScaleDownBehavior": "TERMINATE_AT_INSTANCE_HOUR", "VisibleToAllUsers": true, "BootstrapActions": [], "MasterPublicDnsName": "ec2-xxx-xx-xxx-xx.compute-1.amazonaws.com", "AutoTerminate": false, "Id": "j-xxxxx", "Configurations": [] } }For an AMI based uniform instance group cluster, the output looks like the following.
Output:
{ "Cluster": { "Status": { "Timeline": { "ReadyDateTime": "2014-05-06T14:22:44.432000-0400", "CreationDateTime": "2014-05-06T14:17:48.62000-0400" }, "State": "WAITING", "StateChangeReason": { "Message": "Waiting for steps to run" } }, "Ec2InstanceAttributes": { "IamInstanceProfile": "EMR_EC2_DefaultRole", "Ec2AvailabilityZone": "us-west-2c" }, "Name": "My Cluster", "Tags": [], "TerminationProtected": true, "UnhealthyNodeReplacement": true, "RunningAmiVersion": "2.5.4", "InstanceGroups": [ { "RequestedInstanceCount": 1, "Status": { "Timeline": { "ReadyDateTime": "2014-05-06T14:22:38.848000-0400", "CreationDateTime": "2014-05-06T14:17:48.621000-0400" }, "State": "RUNNING", "StateChangeReason": { "Message": "" } }, "Name": "Master instance group", "InstanceGroupType": "MASTER", "InstanceType": "m1.small", "Id": "ig-ABCD", "Market": "ON_DEMAND", "RunningInstanceCount": 1 }, { "RequestedInstanceCount": 2, "Status": { "Timeline": { "ReadyDateTime": "2014-05-06T14:22:44.439000-0400", "CreationDateTime": "2014-05-06T14:17:48.621000-0400" }, "State": "RUNNING", "StateChangeReason": { "Message": "" } }, "Name": "Core instance group", "InstanceGroupType": "CORE", "InstanceType": "m1.small", "Id": "ig-DEF", "Market": "ON_DEMAND", "RunningInstanceCount": 2 } ], "Applications": [ { "Version": "1.0.3", "Name": "hadoop" } ], "BootstrapActions": [], "VisibleToAllUsers": false, "RequestedAmiVersion": "2.4.2", "LogUri": "s3://amzn-s3-demo-bucketLogUri/", "AutoTerminate": false, "Id": "j-XXXXXXXX" } }For more information, see View Amazon EMR cluster status and details in the Amazon EMR Management Guide.
-
For API details, see DescribeCluster
in AWS CLI Command Reference.
-
- Python
-
- SDK for Python (Boto3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. def describe_cluster(cluster_id, emr_client): """ Gets detailed information about a cluster. :param cluster_id: The ID of the cluster to describe. :param emr_client: The Boto3 EMR client object. :return: The retrieved cluster information. """ try: response = emr_client.describe_cluster(ClusterId=cluster_id) cluster = response["Cluster"] logger.info("Got data for cluster %s.", cluster["Name"]) except ClientError: logger.exception("Couldn't get data for cluster %s.", cluster_id) raise else: return cluster-
For API details, see DescribeCluster in AWS SDK for Python (Boto3) API Reference.
-
- SAP ABAP
-
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. oo_result = lo_emr->describecluster( iv_clusterid = iv_cluster_id ). DATA(lo_cluster) = oo_result->get_cluster( ). DATA(lv_cluster_name) = lo_cluster->get_name( ). MESSAGE |Retrieved cluster information for { lv_cluster_name }| TYPE 'I'. CATCH /aws1/cx_emrinternalserverex INTO DATA(lo_internal_error). DATA(lv_error) = lo_internal_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. CATCH /aws1/cx_emrinvalidrequestex INTO DATA(lo_invalid_error). lv_error = lo_invalid_error->if_message~get_text( ). MESSAGE lv_error TYPE 'E'. ENDTRY.-
For API details, see DescribeCluster in AWS SDK for SAP ABAP API reference.
-