当前位置: 首页 > 知识库问答 >
问题:

无法将Spring Boot度量发布到GCP stackdriver

宋昊然
2023-03-14

我试图将在GCP计算引擎中运行的spring boot(2.2.6.release)应用程序的指标发布到StackDriver。我添加了Micrometer-Registry-StackDriver:1.3.6Spring-Boot-Actuator的依赖关系。Stackdriver metrics客户机配置按照千分尺链接中给出的方法进行。在VM中,我已经安装了这里提到的云监视代理。

如果我缺少任何其他配置,有人能通知我吗?

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.

更新:-在将micrometer版本升级到1.5.1后,我能够将度量发布到stackdriver

共有1个答案

蓬弘
2023-03-14

首先,检查是否具有io.micrometer:micrometer-core依赖项。其次,根据我的经验,让您的meterregistry()bean返回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
 类似资料:
  • 我正在尝试根据下面的代码提出帖子请求: 此请求不需要身份验证,也不需要登录和密码。在邮递员那里,我可以成功地提出请求,但当我尝试执行上述代码时,我得到了: 401未经授权 我在邮递员那里模拟了错误,它给了我下面的信息: 当我在Postman中将身份验证方法更改为“No Auth”时,请求运行良好。 我想我必须在代码中设置这个选项“No Auth”,但我不知道如何设置。 我这样做: 但错误仍在继续。

  • 问题内容: 我是Android应用程序开发的新手。请找到我的AsyncTask代码,用于在用户单击按钮时连接URL。 请参阅我的MainActivity方法: 在这里,我遇到了一个错误。我不知道我的代码有什么问题。谁能帮帮我吗 ? 问题答案: 错了 您不应创建活动类的实例。 活动由开始。 您可以将asynctask设为活动类的内部类,并在其中更新ui 或使用界面 如何从AsyncTask返回布尔值

  • 背景:我正在尝试迁移项目,以使用新的、升级的nexus实例,而不是旧的。Gradle项目和Maven项目进展顺利,但Grails项目进展并不顺利。 问题:发布和单独发布无法发布到新的nexus。快照发布工作正常。在旧的nexus中,快照和发布都工作得很好,我之前提到的使用相同用户凭据的Maven和Gradle项目也工作得很好。 错误如下 POM生成: /var/atlassian/applicat

  • 当我尝试使用以下命令将数据发布到我的REST API(使用Spring DATA JPA REST创建)时: 我得到这个错误:

  • 问题内容: 我已经为jenkins安装了logstash插件,并将其配置为使用索引器作为弹性搜索。 在执行作业时,我看到以下错误: 我们将提供有关如何解决此错误的任何线索。 谢谢-Prateek 问题答案: 在Jenkins插件上,您需要定义包含[yourindex] / [yourtype]的elasticsearch网址,如下所示: http:// localhost:9200 / youri

  • 问题内容: 我试图向laravel发送json的发布请求。该请求在服务器上收到,但是当我尝试访问属性时,我得到: “试图获取非对象的属性” 。在客户端上,我正在使用angularjs。 角度: laravel: 注意:我可以在Fiddler中看到正在发送的JSON是有效的,并且到达了controller + method(http 200)。 帖子请求本身(如Fiddler所示) 问题答案: La