Hi,
Using Eclipse to create a Spring Boot 2.0.0.RELEASE starter project with MVC + Actuator + Spring Cloud AWS Finchley.M8 + AWS Actuator and turning on Spring Cloudwatch export metrics via
spring.metrics.export.cloudwatch.namespace=somenamespace
I get the following error
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method webMvcMetricsFilter in org.springframework.boot.actuate.autoconfigure.metrics.web.servlet.WebMvcMetricsAutoConfiguration required a single bean, but 2 were found:
- simpleMeterRegistry: defined by method 'simpleMeterRegistry' in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.class]
- cloudWatchMeterRegistry: defined by method 'cloudWatchMeterRegistry' in class path resource [org/springframework/cloud/aws/autoconfigure/metrics/CloudWatchExportAutoConfiguration.class]
which I assume is a bug. What's worse is there is no workaround as turning off SimpleMetricsExportAutoConfiguration using management.metrics.export.simple.enabled=false
results in another similar issue:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method webMvcMetricsFilter in org.springframework.boot.actuate.autoconfigure.metrics.web.servlet.WebMvcMetricsAutoConfiguration required a single bean, but 2 were found:
- noOpMeterRegistry: defined by method 'noOpMeterRegistry' in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/NoOpMeterRegistryConfiguration.class]
- cloudWatchMeterRegistry: defined by method 'cloudWatchMeterRegistry' in class path resource [org/springframework/cloud/aws/autoconfigure/metrics/CloudWatchExportAutoConfiguration.class]
Action:
Thanks
Same with WebFlux. Was working in a prior Finchley milestone (or spring boot ?)
Description:
Parameter 0 of method webfluxMetrics in org.springframework.boot.actuate.autoconfigure.metrics.web.reactive.WebFluxMetricsAutoConfiguration required a single bean, but 2 were found:
- simpleMeterRegistry: defined by method 'simpleMeterRegistry' in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.class]
- cloudWatchMeterRegistry: defined by method 'cloudWatchMeterRegistry' in class path resource [org/springframework/cloud/aws/autoconfigure/metrics/CloudWatchExportAutoConfiguration.class]
Hi @mathieufortin01 , I temporarily got around this issue by copying CloudWatchExportAutoConfiguration, CloudWatchProperties & CloudWatchPropertiesConfigAdapter to a local JAR and the key is adding @AutoConfigureBefore(SimpleMetricsExportAutoConfiguration.class) to CloudWatchExportAutoConfiguration.
Thanks
P.S. I also changed the metric key "spring.metrics.export.cloudwatch" to something else so I don't clash with the spring cloud aws config key.
Hi.
I'm now migrating to boot 2 and having same issue in spring-cloud-aws-autoconfigure:2.0.0.M4
Should we change key from spring.metrics.export.cloudwatch to management.metrics.export.cloudwatch same as spring-boot 2 properties ?
I compared the CloudWatchExportAutoConfiguration with one from spring-boot-actuator-autoconfigure for Datadog. Looks like we are missing a AutoConfigureBefore annotation and by the time the bean is created simpleMeterRegistry is already created as a fallback.
As a workaround I copied CloudWatchExportAutoConfiguration and CloudWatchPropertiesConfigAdapter into my project with the added AutoConfigureBefore which fixed this error for me.
PS: to get it finally working I also head to hardcode batchSize() to return 20 ;-)
Most helpful comment
Hi @mathieufortin01 , I temporarily got around this issue by copying CloudWatchExportAutoConfiguration, CloudWatchProperties & CloudWatchPropertiesConfigAdapter to a local JAR and the key is adding
@AutoConfigureBefore(SimpleMetricsExportAutoConfiguration.class)to CloudWatchExportAutoConfiguration.Thanks
P.S. I also changed the metric key "spring.metrics.export.cloudwatch" to something else so I don't clash with the spring cloud aws config key.