Question

Is there an AWS API method (or other procedure) to determine the number of clients connected to a given Elastic Load Balancer?

Reviewing the ELB API documentation there does not seem to be a way. CloudWatch also does not seem to provide a method. Hoping to find some solutions / workarounds.

Was it helpful?

Solution

After much research it appears that the answer is - no - there is no out of the box solution provided by AWS.

However with a simple script running on each node, we can push data into CloudWatch and retrieve the data via the CloudWatch API.

#!/bin/bash

export JAVA_HOME=/usr/java/latest

export AWS_CLOUDWATCH_HOME=/opt/aws

cd /opt/aws

./bin/mon-put-data -n 'Custom/connCounts' -m 'ConnectionCounts' -v `netstat -anp | awk '{print $4" "$6}' |grep 'PORT_NUMBER ESTABLISHED' | wc -l` --aws-credential-file /opt/aws/.ec2config
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top