Skip to content

The `health-check` command-line tool concurrently checks all target groups' health status.

Notifications You must be signed in to change notification settings

warrensbox/health-check

Repository files navigation

Build Status Go Report Card CircleCI

AWS Target Group Health Checker

drawing

The health-check command-line tool concurrently checks all target groups' health status (for target groups that are attached to a load balancer).

The program returns 0 when you have at least one healthy target for each service.

Installation

health-check is available for MacOS and Linux based operating systems.

Homebrew

Installation for MacOS is the easiest with Homebrew. If you do not have homebrew installed, click here.

brew install warrensbox/tap/health-check

Linux

Installation for other linux operation systems.

curl -L https://raw.githubusercontent.com/warrensbox/health-check/release/install.sh | bash

Docker

docker pull warrensbox/health-check:latest

or

docker pull docker.pkg.github.com/warrensbox/health-check/health-check:latest

Install from source

Alternatively, you can install the binary from source here

How to use

Pass your ecs-cluster name

drawing

  1. You must always provide the ecs-cluster on the command-line
  2. Optionally, you can provide the delay option to delay in-between checks
  3. Optionally, you can also provide the attempts option for the number of attempts for the health check

Use the -e option to exit with 1 when unhealthy

drawing

  1. You you provide the -e flag, the program will exit with exit code 1 if any of the target is unhealthy
  2. This is useful for continuous delivery - Jenkins, CircleCI and others

drawing

  1. Likewise, if you dont't provide the -e flag, the program will simply exit with exit code 0 if any of the target is unhealthy

Use the -b option to disable progress bar

drawing

On jenkins you may not want the progress bar to be printed out as it prints out the progress line by line. You can use the -b option to disable progress bar. By default, it prints the progress bar.

With Docker

docker run --rm \
  -e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
  -e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
  -e AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN} \
  -e AWS_REGION=${AWS_REGION} \
  -e AWS_DEFAULT_REGION=${AWS_REGION} \
  health-check --ecs-cluster esp-devops --attempts 50 --delay 2 

How it works

drawing

  1. This command line tool only queries all target group that is attached to a load balancer.
  2. Given an ecs cluster is provided, it concurrently checks for the health status for all target groups in that cluster.
  3. If a target groups shows at least 1 healthy task, it will return the check while other target groups health checks are concurrently going on.
  4. This way, instead of using a loop to check each target group health status - one after another, we can minimize the time by checking all the target groups' health concurrently. The total wait time for the results would be the number of attempts X delay time(in seconds).
  5. The program will not exit with error code 1 unless you pass the -e flag for any unhealthy targets.

CICD

Want new feature? Want to contibute?

Please open issues here: New Issue

Or open a Pull Request.