Spring boot Spring boot metrics statsd赢得';开始

Spring boot Spring boot metrics statsd赢得';开始,spring-boot,spring-boot-actuator,statsd,Spring Boot,Spring Boot Actuator,Statsd,我已经建立了一个spring boot服务应用程序,并且运行良好。 现在我想在我的服务中添加监控功能。目前我在本地计算机上运行statsd记录器。 因此,我开始实施以下指标: ,但它无法启动 以下是我补充的内容: pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</a

我已经建立了一个spring boot服务应用程序,并且运行良好。 现在我想在我的服务中添加监控功能。目前我在本地计算机上运行statsd记录器。 因此,我开始实施以下指标: ,但它无法启动

以下是我补充的内容:

pom.xml

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-core</artifactId>
    <optional>true</optional>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-spring-legacy</artifactId>
    <version>1.0.6</version>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-statsd</artifactId>
    <version>${micrometer.version}</version>
</dependency>
然后,我在启动服务时发现此错误:

...
...
...
10:19:57.088 [main] INFO  org.eclipse.jetty.server.Server:411 - Started @8790ms 
10:19:58.517 [main] INFO  o.s.w.s.m.m.a.RequestMappingHandlerAdapter:574 - Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@564fabc8: startup date [Mon Sep 24 10:19:50 WIB 2018]; root of context hierarchy 
10:19:58.697 [main] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext:558 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'metricsAsyncRestTemplateInitializer' defined in class path resource [io/micrometer/spring/autoconfigure/web/client/RestTemplateMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'metricsAsyncRestTemplateInitializer' parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'io.micrometer.spring.web.client.MetricsRestTemplateCustomizer' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} 
10:19:58.701 [main] INFO  o.s.o.j.LocalContainerEntityManagerFactoryBean:597 - Closing JPA EntityManagerFactory for persistence unit 'default' 
10:19:58.703 [main] INFO  com.jolbox.bonecp.BoneCP:159 - Shutting down connection pool... 
10:19:58.709 [main] INFO  com.jolbox.bonecp.BoneCP:188 - Connection pool has been shutdown. 
10:19:58.757 [main] INFO  org.eclipse.jetty.server.session:167 - node0 Stopped scavenging 
10:19:58.761 [main] INFO  o.e.j.server.handler.ContextHandler:1020 - Stopped o.s.b.w.e.j.JettyEmbeddedWebAppContext@1a01ffff{application,/user-service,[file:///private/var/folders/83/kwg9txkx3cjgcw79_rz4dqr40000gn/T/jetty-docbase.3480800862360239089.8080/, jar:file:/Users/company/.m2/repository/io/springfox/springfox-swagger-ui/2.4.0/springfox-swagger-ui-2.4.0.jar!/META-INF/resources],UNAVAILABLE} 
10:19:58.797 [main] INFO  o.s.b.a.l.ConditionEvaluationReportLoggingListener:101 - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 
10:19:58.978 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter:42 - 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of method metricsAsyncRestTemplateInitializer in io.micrometer.spring.autoconfigure.web.client.RestTemplateMetricsAutoConfiguration required a bean of type 'io.micrometer.spring.web.client.MetricsRestTemplateCustomizer' that could not be found.


Action:

Consider defining a bean of type 'io.micrometer.spring.web.client.MetricsRestTemplateCustomizer' in your configuration.


Process finished with exit code 1
statsd logger实际从我的服务接收消息时:

⇒  statsd-logger
Server listening on 0.0.0.0:8125
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: jvm.gc.pause 10|ms|#action:end of minor GC,cause:Allocation Failure
StatsD Metric: jvm.gc.memory.promoted 8192|c|#statistic:count
StatsD Metric: jvm.gc.memory.allocated 169345024|c|#statistic:count
StatsD Metric: logback.events 1|c|#statistic:count,level:warn
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: jvm.gc.pause 21|ms|#action:end of minor GC,cause:Allocation Failure
StatsD Metric: jvm.gc.memory.promoted 4862520|c|#statistic:count
StatsD Metric: jvm.gc.memory.allocated 260046848|c|#statistic:count
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: jvm.gc.pause 15|ms|#action:end of minor GC,cause:Metadata GC Threshold
StatsD Metric: jvm.gc.memory.promoted 4653536|c|#statistic:count
StatsD Metric: jvm.gc.memory.allocated 255163952|c|#statistic:count
StatsD Metric: jvm.gc.pause 122|ms|#action:end of major GC,cause:Metadata GC Threshold
StatsD Metric: jvm.gc.memory.promoted 7943104|c|#statistic:count
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:warn
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: logback.events 1|c|#statistic:count,level:info
StatsD Metric: jvm.gc.max.data.size 2863661056|g|#statistic:value
StatsD Metric: jvm.gc.live.data.size 39307296|g|#statistic:value
StatsD Metric: jvm.buffer.count 3|g|#statistic:value,id:direct
StatsD Metric: jvm.buffer.memory.used 11342|g|#statistic:value,id:direct
StatsD Metric: jvm.buffer.total.capacity 11341|g|#statistic:value,id:direct
StatsD Metric: jvm.buffer.count 0|g|#statistic:value,id:mapped
StatsD Metric: jvm.buffer.memory.used 0|g|#statistic:value,id:mapped
StatsD Metric: jvm.buffer.total.capacity 0|g|#statistic:value,id:mapped
StatsD Metric: jvm.memory.used 10629696|g|#statistic:value,area:nonheap,id:Code Cache
StatsD Metric: jvm.memory.committed 10813440|g|#statistic:value,area:nonheap,id:Code Cache
StatsD Metric: jvm.memory.max 251658240|g|#statistic:value,area:nonheap,id:Code Cache
StatsD Metric: jvm.memory.used 57925344|g|#statistic:value,area:nonheap,id:Metaspace
StatsD Metric: jvm.memory.committed 60841984|g|#statistic:value,area:nonheap,id:Metaspace
StatsD Metric: jvm.memory.max -1|g|#statistic:value,area:nonheap,id:Metaspace
StatsD Metric: jvm.memory.used 8082776|g|#statistic:value,area:nonheap,id:Compressed Class Space
StatsD Metric: jvm.memory.committed 8675328|g|#statistic:value,area:nonheap,id:Compressed Class Space
StatsD Metric: jvm.memory.max 1073741824|g|#statistic:value,area:nonheap,id:Compressed Class Space
StatsD Metric: jvm.memory.used 32060744|g|#statistic:value,area:heap,id:PS Eden Space
StatsD Metric: jvm.memory.committed 336592896|g|#statistic:value,area:heap,id:PS Eden Space
StatsD Metric: jvm.memory.max 1387790336|g|#statistic:value,area:heap,id:PS Eden Space
StatsD Metric: jvm.memory.used 0|g|#statistic:value,area:heap,id:PS Survivor Space
StatsD Metric: jvm.memory.committed 20971520|g|#statistic:value,area:heap,id:PS Survivor Space
StatsD Metric: jvm.memory.max 20971520|g|#statistic:value,area:heap,id:PS Survivor Space
StatsD Metric: jvm.memory.used 39307296|g|#statistic:value,area:heap,id:PS Old Gen
StatsD Metric: jvm.memory.committed 224919552|g|#statistic:value,area:heap,id:PS Old Gen
StatsD Metric: jvm.memory.max 2863661056|g|#statistic:value,area:heap,id:PS Old Gen
StatsD Metric: jvm.threads.peak 39|g|#statistic:value
StatsD Metric: jvm.threads.daemon 23|g|#statistic:value
StatsD Metric: jvm.threads.live 33|g|#statistic:value
StatsD Metric: jvm.classes.loaded 11729|g|#statistic:value
StatsD Metric: jvm.classes.unloaded 0|c|#statistic:count
StatsD Metric: process.uptime 9105|g|#statistic:value
StatsD Metric: process.start.time 1537762685461|g|#statistic:value
StatsD Metric: system.cpu.count 8|g|#statistic:value
StatsD Metric: system.load.average.1m 3.060059|g|#statistic:value
StatsD Metric: system.cpu.usage 0|g|#statistic:value
StatsD Metric: process.cpu.usage 0|g|#statistic:value
StatsD Metric: process.files.open 184|g|#statistic:value
StatsD Metric: process.files.max 10240|g|#statistic:value
StatsD Metric: statsd.queue.size 0|g|#statistic:value
StatsD Metric: statsd.queue.capacity 2147483647|g|#statistic:value

有没有人经历过同样的问题?我可能遗漏了什么?

我认为缺少customizer bean的错误与statsd集成没有任何关系,请确保您有其他定制

作为补充说明:假设您使用的是SpringBoot2,您不需要

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-spring-legacy</artifactId>
    <version>1.0.6</version>
</dependency>

移除此spring遗留块解决了此问题。谢谢,不客气。根据我的经验:当已经使用Spring启动程序时,总是争取手动添加最少的依赖项。
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-spring-legacy</artifactId>
    <version>1.0.6</version>
</dependency>
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-core</artifactId>
    <optional>true</optional>
</dependency>