springspring-bootspring-micrometerdynatrace

Error Creating Metric in Dynatrace with Spring Boot and Micrometer


I want to send the metrics of my Spring Boot application to Dynatrace. The application uses Spring Boot 2.2.3 and the Micrometer version is 1.3.2. In the application.yaml file the properties for the Dynatrace URL, the API-token and the Device-Id are set. When the application is started the logs show the following error:

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>

The PUT-Request returns the error:

405 Method Not Allowed

In principle, the request conforms to the API Documentation https://www.dynatrace.com/support/help/extend-dynatrace/dynatrace-api/environment-api/metric-v1/custom-metrics/put-custom-metric/ The only difference I see, is that the API-token is sent as a Request Parameter and not as an Authorization Header, as required by the documentation. Is this an error in the Micromenter adapter for Dynatrace?


Solution

  • Your URL contains "/api/api/", which is likely wrong, try with only one "api" in the URL.