Enabling Metrics for the AWS SDK for Java (original) (raw)

The AWS SDK for Java can generate metrics for visualization and monitoring withAmazon CloudWatch that measure:

How to Enable Java SDK Metric Generation

You need to add the following Maven dependency to enable the SDK to send metrics to CloudWatch.

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.amazonaws</groupId>
      <artifactId>aws-java-sdk-bom</artifactId>
      <version>1.12.490*</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
<dependencies>
  <dependency>
    <groupId>com.amazonaws</groupId>
    <artifactId>aws-java-sdk-cloudwatchmetrics</artifactId>
    <scope>provided</scope>
  </dependency>
  <!-- Other SDK dependencies. -->
</dependencies>

*Replace the version number with the latest version of the SDK available at Maven Central.

AWS SDK for Java metrics are disabled by default. To enable it for your local development environment, include a system property that points to your AWS security credential file when starting up the JVM. For example:

-Dcom.amazonaws.sdk.enableDefaultMetrics=credentialFile=/path/aws.properties

You need to specify the path to your credential file so that the SDK can upload the gathered datapoints to CloudWatch for later analysis.

Note

If you are accessing AWS from an Amazon EC2 instance using the Amazon EC2 instance metadata service, you don’t need to specify a credential file. In this case, you need only specify:

-Dcom.amazonaws.sdk.enableDefaultMetrics

All metrics captured by the AWS SDK for Java are under the namespace AWSSDK/Java, and are uploaded to the CloudWatch default region (us-east-1). To change the region, specify it by using the cloudwatchRegion attribute in the system property. For example, to set the CloudWatch region to us-east-1, use:

-Dcom.amazonaws.sdk.enableDefaultMetrics=credentialFile=/path/aws.properties,cloudwatchRegion={region_api_default}

Once you enable the feature, every time there is a service request to AWS from the AWS SDK for Java, metric data points will be generated, queued for statistical summary, and uploaded asynchronously to CloudWatch about once every minute. Once metrics have been uploaded, you can visualize them using the AWS Management Console and set alarms on potential problems such as memory leakage, file descriptor leakage, and so on.

Available Metric Types

The default set of metrics is divided into three major categories:

AWS Request Metrics

AWS service Metrics

Machine Metrics

-Dcom.amazonaws.sdk.enableDefaultMetrics=credentialFile=/path/aws.properties,excludeMachineMetrics  

More Information