1

I'm trying to follow the instructions here.

I've added -Dcom.amazonaws.sdk.enableDefaultMetrics=cloudwatchRegion=eu-west-2 to the java options. I also added the following dependencies in the maven pom:

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-cloudwatch</artifactId>
    <version>1.11.557</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-dynamodb</artifactId>
    <version>1.11.557</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-core</artifactId>
    <version>1.11.557</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-cloudwatchmetrics</artifactId>
    <version>1.11.557</version>
    <scope>provided</scope>
</dependency>

The docker container runs fine on an ec2 instance with the correct iam role and policies. However, there are no CloudWatch namespaces for AWS SDK/Java as the documentation suggests.

3
  • Are you using ECS or running containers directly on ec2? Commented May 27, 2019 at 16:52
  • I am running the containers on ec2 swarm cluster Commented May 28, 2019 at 10:33
  • The docs state to use "-Dcom.amazonaws.sdk.enableDefaultMetrics" if you're running on EC2. However, this will only work if your EC2 instances have an IAM Role attached to them and that IAM Role must have permissions to call cloudwatch:PutMetricData. Commented May 28, 2019 at 12:44

1 Answer 1

1

This uses another dependency, change the aws-java-sdk-cloudwatch to aws-java-sdk-cloudwatchmetrics.

<dependency>
  <groupId>com.amazonaws</groupId>
  <artifactId>aws-java-sdk-cloudwatchmetrics</artifactId>
  <version>1.11.557</version>
  <scope>provided</scope>
</dependency>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.