required a bean of type 'io.micrometer.core.instrument.MeterRegistry' that could not be found
Asked Answered
F

3

7

Recently we upgraded spring-boot version to 2.7.2 and spring framework version to 5.3.22. Since then we are seeing this error in one of the apps

"required a bean of type 'io.micrometer.core.instrument.MeterRegistry' that could not be found."

Spring documentation says that if there is a dependency called micrometer-registry-<?> then it will autowire the required MeterRegistry. We do have that dependency in out project. But it is not happening.

We do have the following properties in application.yml. But actuator is also not working

management:
  metrics:
    export:
      statsd:
        enabled: true
        flavor: datadog
        host: localhost
        port: 8125
  endpoints:
    web:
      exposure:
        include: "*"
  metrics:
    enabled: true

Can some one please tell me what i am missing here?

Fingering answered 24/8, 2022 at 11:51 Comment(0)
P
13

You need spring-boot-starter-actuator on your classpath.

Playacting answered 29/8, 2022 at 20:35 Comment(5)
I already have it as a dependency. But it still is not working.Fingering
It might not be on your classpath (in your jar, etc.)Playacting
It is there. I double checked. Anyway we had downgrade the spring framework to make this workFingering
Helped for me to see the traceId and correlationId: 2022-12-25T02:12:13.991+03:00 INFO [Sender,63a7874db0f29789c75af5dda9c24af4,c75af5dda9c24af4] Tonguelashing
Note that it must be spring-boot-starter-actuator (as the answer points out), and not spring-boot-actuator, which looks really similar, but will leave you scratching your head for a good while.United
E
0

You have problem with your configuration, because of double "management.metrics". Move metrics.enabled in the first block.

Elihu answered 2/5, 2023 at 13:46 Comment(0)
B
0

If the below config is false

management.metrics.export.graphite.enabled=false

And you have MeterRegistryCustomizer beans defined, you will get this error

SimpleMeterRegistry cannot be cast to class io.micrometer.graphite.GraphiteMeterRegistry

Resolution:

Set to true

management.metrics.export.graphite.enabled=true

Balanchine answered 6/6 at 13:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.