我正在尝试按照此处的说明进行操作。
我已添加-Dcom.amazonaws.sdk.enableDefaultMetrics=cloudwatchRegion=eu-west-2
到 java 选项。我还在 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>
docker 容器在具有正确 iam 角色和策略的 ec2 实例上运行良好。但是,正如文档所建议的那样,AWS SDK/Java 没有 CloudWatch 命名空间。