This version is still in development and is not considered stable yet. For the latest stable version, please use Micrometer 1.14.2!

Micrometer CloudWatch

Amazon CloudWatch is a dimensional time-series SaaS on Amazon’s cloud.

1. Installing micrometer-registry-cloudwatch2

It is recommended to use the BOM provided by Micrometer (or your framework if any), you can see how to configure it here. The examples below assume you are using a BOM.

1.1. Gradle

After the BOM is configured, add the following dependency:

implementation 'io.micrometer:micrometer-registry-cloudwatch2'
The version is not needed for this dependency since it is defined by the BOM.

1.2. Maven

After the BOM is configured, add the following dependency:

<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-registry-cloudwatch2</artifactId>
</dependency>
The version is not needed for this dependency since it is defined by the BOM.

2. Configuring

The following example configures Micrometer CloudWatch:

CloudWatchConfig cloudWatchConfig = new CloudWatchConfig() {
    @Override
    public String get(String s) {
        return null;
    }

    @Override
    public String namespace() {
        return "mynamespace";
    }
};
MeterRegistry meterRegistry = new CloudWatchMeterRegistry(cloudWatchConfig, Clock.SYSTEM, CloudWatchAsyncClient.create());

You can provide your own CloudWatchAsyncClient to the constructor of the registry.

CloudWatchConfig is an interface with a set of default methods. If, in the implementation of get(String k), rather than returning null, you instead bind it to a property source, you can override the default configuration. For example, Micrometer support in Spring Cloud AWS binds properties prefixed with management.metrics.export.cloudwatch directly to the CloudWatchConfig:

management.metrics.export.cloudwatch:
    namespace: YOURNAMESPACE

    # You will probably want to disable publishing in a local development profile.
    enabled: true

    # The interval at which metrics are sent to CloudWatch. The default is 1 minute.
    step: 1m