Publish SDK metrics from the AWS SDK for Java - AWS SDK for Java 2.x

Publish SDK metrics from the AWS SDK for Java

With the AWS SDK for Java 2.x, you can collect metrics about the service clients and requests in your application, analyze the output in Amazon CloudWatch, and then act on it.

By default, metrics collection is disabled in the SDK. This topic helps you to enable and configure it.

What are the different MetricPublisher implementations?

The SDK for Java 2.x offers three implementations of the MetricPublisher interface. Each implementation is geared for different use cases and shown in the following table:

MetricPublisher implementation Suitable use case
CloudWatchMetricPublisher Long-running applications
EmfMetricLoggingPublisher AWS Lambda functions
LoggingMetricPublisher Console output for troubleshooting

When are metrics available?

Metrics are generally available within 5-10 minutes after the SDK for Java emits them. For accurate and up-to-date metrics, check Cloudwatch at least 10 minutes after emitting the metrics from your Java applications.

What information is collected?

Metrics collection includes the following:

  • Number of API requests, including whether they succeed or fail

  • Information about the AWS services you call in your API requests, including exceptions returned

  • The duration for various operations such as Marshalling, Signing, and HTTP requests

  • HTTP client metrics, such as the number of open connections, the number of pending requests, and the name of the HTTP client used

Note

The metrics available vary by HTTP client.

For a complete list, see Service client metrics.

How can I use this information?

You can use the metrics the SDK collects to monitor the service clients in your application. You can look at overall usage trends, identify anomalies, review service client exceptions returned, or to dig in to understand a particular issue. Using Amazon CloudWatch, you can also create alarms to notify you as soon as your application reaches a condition that you define.

For more information, see Using Amazon CloudWatch Metrics and Using Amazon CloudWatch Alarms in the Amazon CloudWatch User Guide.

Topics