get_target_health
Retrieve health status of targets in an AWS Target Group to monitor application availability and troubleshoot load balancing issues.
Instructions
Retrieves the health of targets in a specified Target Group.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_group_arn | Yes | The ARN of the Target Group. |
Implementation Reference
- src/index.ts:1996-2007 (handler)Handler implementation for the 'get_target_health' tool. It takes a target group ARN, calls DescribeTargetHealthCommand using the ELBv2 client, processes the target health descriptions, and returns a JSON-formatted list of target health statuses.if (name === "get_target_health") { const tgArn = (args as any)?.target_group_arn; const command = new DescribeTargetHealthCommand({ TargetGroupArn: tgArn }); const response = await elbv2Client.send(command); const healths = response.TargetHealthDescriptions?.map(th => ({ Target: { Id: th.Target?.Id, Port: th.Target?.Port }, State: th.TargetHealth?.State, Reason: th.TargetHealth?.Reason, Description: th.TargetHealth?.Description })) || []; return { content: [{ type: "text", text: JSON.stringify(healths, null, 2) }] }; }
- src/index.ts:592-605 (registration)Registration of the 'get_target_health' tool in the ListTools response, including name, description, and input schema.{ name: "get_target_health", description: "Retrieves the health of targets in a specified Target Group.", inputSchema: { type: "object", properties: { target_group_arn: { type: "string", description: "The ARN of the Target Group." } }, required: ["target_group_arn"] } },
- src/index.ts:595-604 (schema)Input schema definition for the 'get_target_health' tool, specifying the required target_group_arn parameter.inputSchema: { type: "object", properties: { target_group_arn: { type: "string", description: "The ARN of the Target Group." } }, required: ["target_group_arn"] }
- src/index.ts:67-67 (helper)Initialization of the ELBv2 client used by the get_target_health handler.const elbv2Client = new ElasticLoadBalancingV2Client({});
- src/index.ts:33-33 (helper)Import of ElasticLoadBalancingV2Client and DescribeTargetHealthCommand (among others) required for the tool implementation.import { ElasticLoadBalancingV2Client, DescribeLoadBalancersCommand, DescribeTargetGroupsCommand, DescribeTargetHealthCommand, DescribeListenersCommand, DescribeRulesCommand } from "@aws-sdk/client-elastic-load-balancing-v2";