Skip to content

describe_target_health

describe_target_health(
    *,
    config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
    target_group_arn: Optional[TargetGroupArn] = None,
    targets: Optional[TargetDescriptions] = None,
    include: Optional[ListOfDescribeTargetHealthIncludeOptions] = None,
) -> DescribeTargetHealthOutput

Describes the health of the specified targets or all of your targets.

Parameters:

Raises:

Examples:

To describe the health of the targets for a target group 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.

>>> client.describe_target_health(target_group_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067')
To describe the health of a target
This example describes the health of the specified target. This target is healthy.
>>> client.describe_target_health(target_group_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067', targets=[{'Id': 'i-0f76fade', 'Port': 80}])
Source code in docs_src/capo_elastic_load_balancing_v2/_services/elastic_load_balancingv2.py
def describe_target_health(
    self,
    *,
    config_overrides: Optional[ElasticLoadBalancingv2ClientConfig] = None,
    target_group_arn: Optional[
        "capo_elastic_load_balancing_v2.types.target_group_arn.TargetGroupArn"
    ] = None,
    targets: Optional[
        "capo_elastic_load_balancing_v2.types.target_descriptions.TargetDescriptions"
    ] = None,
    include: Optional[
        "capo_elastic_load_balancing_v2.types.list_of_describe_target_health_include_options.ListOfDescribeTargetHealthIncludeOptions"
    ] = None,
) -> "capo_elastic_load_balancing_v2.types.describe_target_health_output.DescribeTargetHealthOutput":
    """<p>Describes the health of the specified targets or all of your targets.</p>

    Args:
        target_group_arn: <p>The Amazon Resource Name (ARN) of the target group.</p>
        targets: <p>The targets.</p>
        include: <p>Used to include anomaly detection information.</p>

    Raises:
        capo_elastic_load_balancing_v2.errors.health_unavailable_exception.HealthUnavailableException: <p>The health of the specified targets could not be retrieved due to an internal error.</p>
        capo_elastic_load_balancing_v2.errors.invalid_target_exception.InvalidTargetException: <p>The specified target does not exist, is not in the same VPC as the target group, or has an unsupported instance type.</p>
        capo_elastic_load_balancing_v2.errors.target_group_not_found_exception.TargetGroupNotFoundException: <p>The specified target group does not exist.</p>
        capo_elastic_load_balancing_v2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To describe the health of the targets for a target group
        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.

        >>> client.describe_target_health(target_group_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067')
        To describe the health of a target
        This example describes the health of the specified target. This target is healthy.

        >>> client.describe_target_health(target_group_arn='arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067', targets=[{'Id': 'i-0f76fade', 'Port': 80}])
    """

    def _handler(
        req: "OperationRequest[capo_elastic_load_balancing_v2.types.describe_target_health_input.DescribeTargetHealthInput]",
    ) -> OperationResponse[
        "capo_elastic_load_balancing_v2.types.describe_target_health_output.DescribeTargetHealthOutput"
    ]:
        import capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.describe_target_health

        output, http_response = (
            capo_elastic_load_balancing_v2._operations.elastic_load_balancing_v10.describe_target_health.describe_target_health(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("DescribeTargetHealth")
    )
    input_: capo_elastic_load_balancing_v2.types.describe_target_health_input.DescribeTargetHealthInput = {}
    if target_group_arn is not None:
        input_["target_group_arn"] = target_group_arn
    if targets is not None:
        input_["targets"] = targets
    if include is not None:
        input_["include"] = include

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output