ElasticLoadBalancingv2 / Client / describe_target_health
describe_target_health#
- ElasticLoadBalancingv2.Client.describe_target_health(**kwargs)#
Describes the health of the specified targets or all of your targets.
See also: AWS API Documentation
Request Syntax
response = client.describe_target_health( TargetGroupArn='string', Targets=[ { 'Id': 'string', 'Port': 123, 'AvailabilityZone': 'string' }, ] )
- Parameters:
TargetGroupArn (string) –
[REQUIRED]
The Amazon Resource Name (ARN) of the target group.
Targets (list) –
The targets.
(dict) –
Information about a target.
Id (string) – [REQUIRED]
The ID of the target. If the target type of the target group is
instance
, specify an instance ID. If the target type isip
, specify an IP address. If the target type islambda
, specify the ARN of the Lambda function. If the target type isalb
, specify the ARN of the Application Load Balancer target.Port (integer) –
The port on which the target is listening. If the target group protocol is GENEVE, the supported port is 6081. If the target type is
alb
, the targeted Application Load Balancer must have at least one listener whose port matches the target group port. Not used if the target is a Lambda function.AvailabilityZone (string) –
An Availability Zone or
all
. This determines whether the target receives traffic from the load balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the load balancer.For Application Load Balancer target groups, the specified Availability Zone value is only applicable when cross-zone load balancing is off. Otherwise the parameter is ignored and treated as
all
.This parameter is not supported if the target type of the target group is
instance
oralb
.If the target type is
ip
and the IP address is in a subnet of the VPC for the target group, the Availability Zone is automatically detected and this parameter is optional. If the IP address is outside the VPC, this parameter is required.For Application Load Balancer target groups with cross-zone load balancing off, if the target type is
ip
and the IP address is outside of the VPC for the target group, this should be an Availability Zone inside the VPC for the target group.If the target type is
lambda
, this parameter is optional and the only supported value isall
.
- Return type:
dict
- Returns:
Response Syntax
{ 'TargetHealthDescriptions': [ { 'Target': { 'Id': 'string', 'Port': 123, 'AvailabilityZone': 'string' }, 'HealthCheckPort': 'string', 'TargetHealth': { 'State': 'initial'|'healthy'|'unhealthy'|'unused'|'draining'|'unavailable', 'Reason': 'Elb.RegistrationInProgress'|'Elb.InitialHealthChecking'|'Target.ResponseCodeMismatch'|'Target.Timeout'|'Target.FailedHealthChecks'|'Target.NotRegistered'|'Target.NotInUse'|'Target.DeregistrationInProgress'|'Target.InvalidState'|'Target.IpUnusable'|'Target.HealthCheckDisabled'|'Elb.InternalError', 'Description': 'string' } }, ] }
Response Structure
(dict) –
TargetHealthDescriptions (list) –
Information about the health of the targets.
(dict) –
Information about the health of a target.
Target (dict) –
The description of the target.
Id (string) –
The ID of the target. If the target type of the target group is
instance
, specify an instance ID. If the target type isip
, specify an IP address. If the target type islambda
, specify the ARN of the Lambda function. If the target type isalb
, specify the ARN of the Application Load Balancer target.Port (integer) –
The port on which the target is listening. If the target group protocol is GENEVE, the supported port is 6081. If the target type is
alb
, the targeted Application Load Balancer must have at least one listener whose port matches the target group port. Not used if the target is a Lambda function.AvailabilityZone (string) –
An Availability Zone or
all
. This determines whether the target receives traffic from the load balancer nodes in the specified Availability Zone or from all enabled Availability Zones for the load balancer.For Application Load Balancer target groups, the specified Availability Zone value is only applicable when cross-zone load balancing is off. Otherwise the parameter is ignored and treated as
all
.This parameter is not supported if the target type of the target group is
instance
oralb
.If the target type is
ip
and the IP address is in a subnet of the VPC for the target group, the Availability Zone is automatically detected and this parameter is optional. If the IP address is outside the VPC, this parameter is required.For Application Load Balancer target groups with cross-zone load balancing off, if the target type is
ip
and the IP address is outside of the VPC for the target group, this should be an Availability Zone inside the VPC for the target group.If the target type is
lambda
, this parameter is optional and the only supported value isall
.
HealthCheckPort (string) –
The port to use to connect with the target.
TargetHealth (dict) –
The health information for the target.
State (string) –
The state of the target.
Reason (string) –
The reason code.
If the target state is
healthy
, a reason code is not provided.If the target state is
initial
, the reason code can be one of the following values:Elb.RegistrationInProgress
- The target is in the process of being registered with the load balancer.Elb.InitialHealthChecking
- The load balancer is still sending the target the minimum number of health checks required to determine its health status.
If the target state is
unhealthy
, the reason code can be one of the following values:Target.ResponseCodeMismatch
- The health checks did not return an expected HTTP code. Applies only to Application Load Balancers and Gateway Load Balancers.Target.Timeout
- The health check requests timed out. Applies only to Application Load Balancers and Gateway Load Balancers.Target.FailedHealthChecks
- The load balancer received an error while establishing a connection to the target or the target response was malformed.Elb.InternalError
- The health checks failed due to an internal error. Applies only to Application Load Balancers.
If the target state is
unused
, the reason code can be one of the following values:Target.NotRegistered
- The target is not registered with the target group.Target.NotInUse
- The target group is not used by any load balancer or the target is in an Availability Zone that is not enabled for its load balancer.Target.InvalidState
- The target is in the stopped or terminated state.Target.IpUnusable
- The target IP address is reserved for use by a load balancer.
If the target state is
draining
, the reason code can be the following value:Target.DeregistrationInProgress
- The target is in the process of being deregistered and the deregistration delay period has not expired.
If the target state is
unavailable
, the reason code can be the following value:Target.HealthCheckDisabled
- Health checks are disabled for the target group. Applies only to Application Load Balancers.Elb.InternalError
- Target health is unavailable due to an internal error. Applies only to Network Load Balancers.
Description (string) –
A description of the target health that provides additional details. If the state is
healthy
, a description is not provided.
Exceptions
ElasticLoadBalancingv2.Client.exceptions.InvalidTargetException
ElasticLoadBalancingv2.Client.exceptions.TargetGroupNotFoundException
ElasticLoadBalancingv2.Client.exceptions.HealthUnavailableException
Examples
This example describes the health of the targets for the specified target group. One target is healthy but the other is not specified in an action, so it can’t receive traffic from the load balancer.
response = client.describe_target_health( TargetGroupArn='arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067', ) print(response)
Expected Output:
{ 'TargetHealthDescriptions': [ { 'Target': { 'Id': 'i-0f76fade', 'Port': 80, }, 'TargetHealth': { 'Description': 'Given target group is not configured to receive traffic from ELB', 'Reason': 'Target.NotInUse', 'State': 'unused', }, }, { 'HealthCheckPort': '80', 'Target': { 'Id': 'i-0f76fade', 'Port': 80, }, 'TargetHealth': { 'State': 'healthy', }, }, ], 'ResponseMetadata': { '...': '...', }, }
This example describes the health of the specified target. This target is healthy.
response = client.describe_target_health( TargetGroupArn='arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067', Targets=[ { 'Id': 'i-0f76fade', 'Port': 80, }, ], ) print(response)
Expected Output:
{ 'TargetHealthDescriptions': [ { 'HealthCheckPort': '80', 'Target': { 'Id': 'i-0f76fade', 'Port': 80, }, 'TargetHealth': { 'State': 'healthy', }, }, ], 'ResponseMetadata': { '...': '...', }, }