无法向GCP stackdriver发布spring boot指标

问题描述 投票:3回答:1

我正试图发布我的spring boot()的指标。2.2.6.RELEASE)应用程序在GCP计算引擎中运行,并将其添加到stackdriver中。我已经将 micrometer-registry-stackdriver:1.3.6spring-boot-actuator. Stackdriver度量衡客户端的配置是按照在 千分尺. 在虚拟机中,我已经安装了云监控代理。如前所述.

当运行该应用程序时,我得到的错误是 io.grpc.StatusRuntimeException: INTERNAL: An internal error occurred.

有谁能告诉我,我是否缺少其他配置?

2020-04-29 10:19:16.248  INFO 14905 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3608
ms
2020-04-29 10:19:18.085  INFO 14905 --- [           main] i.m.s.StackdriverMeterRegistry           : publishing metrics to stackdriver every 1m
2020-04-29 10:19:20.058  INFO 14905 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-04-29 10:19:20.735  INFO 14905 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 13 endpoint(s) beneath base path '/actuator'
2020-04-29 10:19:20.897  INFO 14905 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2020-04-29 10:19:20.908  INFO 14905 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 9.375 seconds (JVM running for 10.
417)
2020-04-29 10:19:27.548  INFO 14905 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-04-29 10:19:27.549  INFO 14905 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-04-29 10:19:27.568  INFO 14905 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 19 ms
2020-04-29 10:20:39.832  WARN 14905 --- [trics-publisher] i.m.s.StackdriverMeterRegistry           : failed to send metrics to Stackdriver

com.google.api.gax.rpc.InternalException: io.grpc.StatusRuntimeException: INTERNAL: An internal error occurred.
        at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:67) ~[gax-1.48.1.jar!/:1.48.1]
        at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:72) ~[gax-grpc-1.48.1.jar!/:1.48.1]
        at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:60) ~[gax-grpc-1.48.1.jar!/:1.48.1]
        at com.google.api.gax.grpc.GrpcExceptionCallable$ExceptionTransformingFuture.onFailure(GrpcExceptionCallable.java:97) ~[gax-grpc-1.48.1.jar!/:1.48.1]
        at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:68) ~[api-common-1.8.1.jar!/:na]
        at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:982) ~[guava-28.0-android.jar!/:na]
        at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30) ~[guava-28.0-android.jar!/:na]
        at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1138) ~[guava-28.0-android.jar!/:na]
        at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:957) ~[guava-28.0-android.jar!/:na]
        at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:748) ~[guava-28.0-android.jar!/:na]
        at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:515) ~[grpc-stub-1.23.0.jar!/:1.23.0]
        at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:490) ~[grpc-stub-1.23.0.jar!/:1.23.0]
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) ~[grpc-api-1.23.0.jar!/:1.23.0]
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) ~[grpc-api-1.23.0.jar!/:1.23.0]
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) ~[grpc-api-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:700) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39) ~[grpc-api-1.23.0.jar!/:1.23.0]
        at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23) ~[grpc-api-1.23.0.jar!/:1.23.0]
        at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40) ~[grpc-api-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:399) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:510) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:66) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:630) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$700(ClientCallImpl.java:518) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:692) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:681) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) ~[grpc-core-1.23.0.jar!/:1.23.0]
        at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) ~[grpc-core-1.23.0.jar!/:1.23.0]
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_252]
                at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_252]
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_252]
                at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[na:1.8.0_252]
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_252]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_252]
                at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_252]
                Suppressed: com.google.api.gax.rpc.AsyncTaskException: Asynchronous task failed
                        at com.google.api.gax.rpc.ApiExceptions.callAndTranslateApiException(ApiExceptions.java:57) ~[gax-1.48.1.jar!/:1.48.1]
                        at com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112) ~[gax-1.48.1.jar!/:1.48.1]
                        at com.google.cloud.monitoring.v3.MetricServiceClient.createTimeSeries(MetricServiceClient.java:1156) ~[google-cloud-monitoring-1.93.0.jar!/:1.93.
        0]
                        at io.micrometer.stackdriver.StackdriverMeterRegistry.publish(StackdriverMeterRegistry.java:176) ~[micrometer-registry-stackdriver-1.3.6.jar!/:1.3
        .6]
                        at io.micrometer.core.instrument.push.PushMeterRegistry.publishSafely(PushMeterRegistry.java:48) [micrometer-core-1.3.6.jar!/:1.3.6]
                        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_252]
                        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[na:1.8.0_252]
                        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_252]
                        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[na:1.8.0_252]
                        ... 3 common frames omitted
        Caused by: io.grpc.StatusRuntimeException: INTERNAL: An internal error occurred.
                at io.grpc.Status.asRuntimeException(Status.java:533) ~[grpc-api-1.23.0.jar!/:1.23.0]
                ... 24 common frames omitted
        2020-04-29 10:20:55.181  INFO 14905 --- [nio-8080-exec-5] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header
         Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.

更新:- 当我把微米计的版本升级为 1.5.1

spring-boot-actuator stackdriver google-cloud-stackdriver micrometer spring-micrometer
1个回答
4
投票

首先,检查你是否有 io.micrometer:micrometer-core 依赖性。其次,根据我的经验,让你的 meterRegistry() 回豆 MeterRegistry 而不是 StackdriverMeterRegistry.

@Bean
public MeterRegistry meterRegistry() {
    final StackdriverConfig stackdriverConfig = new StackdriverConfig() {
        @Override
        public String projectId() {
            return "your-project-name";
        }

        @Override
        public String get(final String key) {
            return null; //this field is ignored
        }
    };
    return StackdriverMeterRegistry.builder(stackdriverConfig).build();
}

另外,我希望你有 management.* 属性正确配置。这是我的例子

management:
  endpoints:
    metrics:
      enabled: true
    prometheus:
      enabled: true
    web:
      exposure:
        include: '*'
  metrics:
    tags:
      application: your-app
    export:
      prometheus:
        enabled: true
    stackdriver:
      enabled: true
      step: 1m
© www.soinside.com 2019 - 2024. All rights reserved.