使用 Spring Boot 和 Micrometer 在 Dynatrace 中创建指标时出错

Error Creating Metric in Dynatrace with Spring Boot and Micrometer

我想将 Spring 启动应用程序的指标发送到 Dynatrace。该应用程序使用 Spring Boot 2.2.3,Micrometer 版本为 1.3.2。在 application.yaml 文件中设置了 Dynatrace URL、API-token 和 Device-Id 的属性。当应用程序启动时,日志显示以下错误:

2020-01-24 17:34:03.099 DEBUG 6 --- [trics-publisher] s.n.www.protocol.http.HttpURLConnection  : sun.net.www.MessageHeader@53ddc3e27 pairs: {PUT /e/b63c9b27-de7e-498b-8466-1987a7f6af7d/api/api/v1/timeseries/custom:tomcat.sessions.alive.max?api-token=xxx HTTP/1.1: null}{Content-Type: application/json}{User-Agent: Java/13.0.1}{Host: apm.cf.eu10.hana.ondemand.com}{Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2}{Connection: keep-alive}{Content-Length: 116}
2020-01-24 17:34:03.137 DEBUG 6 --- [trics-publisher] s.n.www.protocol.http.HttpURLConnection  : sun.net.www.MessageHeader@1e1eb5659 pairs: {null: HTTP/1.1 405 Method Not Allowed}{Content-Security-Policy: default-src 'self' 'nonce-p+oZSPTiRzS6ULGJdzTL1g==' data: ;script-src 'self' 'unsafe-eval' localhost:9876 127.0.0.1:9876 localhost:4200 127.0.0.1:4200 https://static.woopra.com https://www.woopra.com/ https://app.intercom.io https://widget.intercom.io https://js.intercomcdn.com https://js-cdn.dynatracelabs.com 'unsafe-inline';object-src 'self' 'nonce-p+oZSPTiRzS6ULGJdzTL1g==' ;style-src 'self' 'unsafe-inline' localhost:9876 127.0.0.1:9876 localhost:4200 127.0.0.1:4200;font-src 'self' 'nonce-p+oZSPTiRzS6ULGJdzTL1g==' localhost:9876 127.0.0.1:9876 localhost:4200 127.0.0.1:4200 https://js.intercomcdn.com;img-src 'self' 'nonce-p+oZSPTiRzS6ULGJdzTL1g==' data: localhost:9876 127.0.0.1:9876 localhost:4200 127.0.0.1:4200 https://ruxit-synth-screencap-dev.s3.amazonaws.com https://ruxit-synth-screencap-sprint.s3.amazonaws.com https://ruxit-synth-screencap.s3.amazonaws.com https://js.intercomcdn.com data: https://static.intercomassets.com https://downloads.intercomcdn.com https://uploads.intercomusercontent.com https://gifs.intercomcdn.com https://dt-cdn.net https://dynatrace.asknice.ly;media-src 'self' 'nonce-p+oZSPTiRzS6ULGJdzTL1g==' https://js.intercomcdn.com;frame-src 'self' 'nonce-p+oZSPTiRzS6ULGJdzTL1g=='  localhost:9876 127.0.0.1:9876 https://www.youtube.com https://fast.wistia.net https://share.intercom.io https://intercom-sheets.com https://player.vimeo.com;connect-src 'self' 'nonce-p+oZSPTiRzS6ULGJdzTL1g==' localhost:9876 127.0.0.1:9876 localhost:4200 127.0.0.1:4200 wss://localhost:4200 wss://127.0.0.1:4200 https://api.segment.io https://trello.com/1/ https://api.intercom.io https://api-iam.intercom.io https://api-ping.intercom.io https://nexus-websocket-a.intercom.io https://nexus-websocket-b.intercom.io https://nexus-long-poller-a.intercom.io https://nexus-long-poller-b.intercom.io wss://nexus-websocket-a.intercom.io wss://nexus-websocket-b.intercom.io https://uploads.intercomcdn.com https://uploads.intercomusercontent.com https://js.intercomcdn.com;child-src 'self' blob:;worker-src 'self' blob:;frame-ancestors 'self' ;base-uri 'self' ;form-action 'self' https://dynatrace.asknice.ly https://api-iam.intercom.io https://accounts.sap.com; report-uri /reportCPSViolations}{Date: Fri, 24 Jan 2020 17:34:03 GMT}{Frame-Options: SAMEORIGIN}{Set-Cookie: apmroute=6c416ea40448a6d5e825253d116a9479; Path=/; Secure; HttpOnly}{Set-Cookie: apmsessionid=node035abqwwf0bk41tgs7gg4yic5l897270.node0;Path=/;Secure;HttpOnly}{X-Vcap-Request-Id: 31a4aa2b-38ca-44c5-5da3-fa60830be4da}{Content-Length: 0}{Strict-Transport-Security: max-age=31536000; includeSubDomains; preload;}
2020-01-24 17:34:03.137 ERROR 6 --- [trics-publisher] i.m.dynatrace.DynatraceMeterRegistry     : failed to create custom metric custom:tomcat.sessions.alive.max in dynatrace: <no response body>

PUT-Request returns 错误:

405 Method Not Allowed

原则上,请求符合API文档https://www.dynatrace.com/support/help/extend-dynatrace/dynatrace-api/environment-api/metric-v1/custom-metrics/put-custom-metric/ 我看到的唯一区别是 API-token 作为请求参数发送,而不是按照文档要求作为授权 Header 发送。 这是 Dynatrace 的 Micromenter 适配器中的错误吗?

您的 URL 包含“/api/api/”,这可能是错误的,请尝试在 URL.

中只使用一个 "api"