Я использовал aws sdk 2, и мне удалось передать метрики в облако с помощью следующей конфигурации, но все контейнеры передают значения одной и той же метрике CloudWatch.
Код: Выделить всё
import io.micrometer.cloudwatch2.CloudWatchConfig;
import io.micrometer.cloudwatch2.CloudWatchMeterRegistry;
import io.micrometer.core.instrument.Clock;
import io.micrometer.core.instrument.MeterRegistry;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient;
import java.time.Duration;
import java.util.Map;
@Configuration
public class MetricsConfiguration {
private String metricsNamespace = "test";
@Bean
public CloudWatchAsyncClient cloudWatchAsyncClient() {
return CloudWatchAsyncClient
.builder()
.build();
}
@Bean
public MeterRegistry getMeterRegistry() {
CloudWatchConfig cloudWatchConfig = setupCloudWatchConfig();
return new CloudWatchMeterRegistry(
cloudWatchConfig,
Clock.SYSTEM,
cloudWatchAsyncClient());
}
private CloudWatchConfig setupCloudWatchConfig() {
return new CloudWatchConfig() {
private final Map configuration = Map.of(
"cloudwatch.namespace", metricsNamespace,
"cloudwatch.step", Duration.ofSeconds(30).toString()
);
@Override
public String get(@NotNull String key) {
return configuration.get(key);
}
};
}
}
Код: Выделить всё
private final Map configuration = Map.of(
"cloudwatch.namespace", metricsNamespace,
"cloudwatch.step", Duration.ofSeconds(30).toString(),
"cloudwatch.container_label", "container_name"
);

(
Код: Выделить всё
service-name
Я ожидаю, что для каждого контейнера для jdbc.connections.active.value будет одна запись метрики
Подробнее здесь: https://stackoverflow.com/questions/790 ... -container