Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cloudwatch: how to fetch custom metrics from AWS Elastic Beanstalk

I'm using latest version of AWS SDK for JavaScript.

I need to get some metrics from AWS Cloudwatch with getMetricStatistics method (http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudWatch.html#getMetricStatistics-property). To use this method, you need to specify Dimensions field.

It works fine if I specify dimensions like this:

{Name: 'InstanceId', Value: SOME_INSTANCE_ID_HERE}

But with Elastic Beanstalk you can't rely on InstanceId, because it might create/destroy instances when it needs. So I tried to use different dimension:

{Name: 'InstanceName', Value: NAME_FROM_ELB}

But it doesn't work. I'm trying to find another way/dimension to access ELB metrics.

like image 842
sap1ens Avatar asked Dec 07 '25 20:12

sap1ens


1 Answers

Finally got a reply from AWS: there is no way to do it, you have to use InstanceId as a dimension. You can get it dynamically using EC2 metadata.

like image 64
sap1ens Avatar answered Dec 10 '25 14:12

sap1ens