How to configure multiple ports with App Health Checks
search cancel

How to configure multiple ports with App Health Checks

book

Article ID: 298381

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

According to the docs for "Using App Health Checks " , it states that if setting Health Check Type with port. See example below: 

A health check makes a TCP connection to the port or ports configured for the app. For apps with multiple ports, a health check monitors each port. 


You may question how to configure multiple ports to monitor them with App Health Checks. This article introduces how to configure multiple ports with App Health Checks.


Environment

Product Version: 2.12

Resolution

First, you will need to develop your target application to listen with multiple ports to be monitored on Tanzu Application Service. For examples, please suppose that your particular application listens with port 7777 and port 8888.

By default, App Health Checks are performed for port 8080 only. You must set the ports manually to monitor with App Health Checks feature as the cf command shows below:
 

cf curl /v2/apps/<TARGET_APP_GUID> -X PUT -d '{"ports": [7777,8888]}' 


This modification is immediately applied. Now, you will see multiple heathcheck processes in Diego Cell VMs hosting the target application instances as shown below and you will see a health check monitors each port:

diego_cell/****97c3-**c0-**5f-**d3-**ec95a4411d:~# ps auxwww | grep healthcheck
  :
4294967+ 2735806  0.0  0.0 706260  4040 ?        Ssl  07:26   0:00 /etc/cf-assets/healthcheck/healthcheck -port=8888 -timeout=1000ms -liveness-interval=30s
4294967+ 2735818  0.0  0.0 706260  4208 ?        Ssl  07:26   0:00 /etc/cf-assets/healthcheck/healthcheck -port=7777 -timeout=1000ms -liveness-interval=30s 

 

Once one of healthcheck processes fails to monitor the target port, the target application is considered as crashed.

If you want to check the actual monitoring behavior with multiple ports quickly, you can use the following sample go application which can listen with multiple ports.