19 Nov 2024 03:22 PM - last edited on 20 Nov 2024 07:31 AM by MaciejNeumann
We have a custom extension V2 in python that performs some healthcheck. It should report back the metrics to Dynatrace with the status and the url used to perform the healthcheck. Our call looks this:
self.report_metric(
key="healthcheck_state",
value="success",
dimensions={"url": "google.be"}
)
When checking the logs on the Active Gate we get the following error back:
Error HTTP 400 from http://127.0.0.1:14599/mint/8460131254161511808: b'{\n "error": {\n "invalidLines": [\n {\n "line": 1,\n "error": "invalid metric field in message \'healthcheck_state,url=\\"google.com\\" gauge,success 1732025455011\'; error at \' \' (index 48)"\n },\n {\n "line": 2,\n "error": "invalid metric field in message \'healthcheck_state,url=\\"google.com\\" gauge,success 1732025455011\'; error at \' \' (index 48)"\n }\n ],\n "code": 400,\n "message": "2 invalid lines"\n },\n "linesOk": 0,\n "linesInvalid": 2\n}'
I guess this means that the validation of the metric fails. After reading about the MINT protocol I still wonder why it fails? I don't see a \ somewhere. Seems to me like the dict is not correctly serialized and the quotes are escaped? Can this be avoided?
Could it be related to this line
def _key_and_dimensions(self):
if not self.dimensions:
return f"{self.key}"
# Double quotes are added around {v} but later escaped.
dimensions_string = ",".join([f'{k}="{v}"' for k, v in self.dimensions.items()])
return f"{self.key},{dimensions_string}"
19 Nov 2024 03:28 PM
You're not doing the metric ingestion correctly. For correct gauge usage, please chek out the documentation and examples here:
https://docs.dynatrace.com/docs/ingest-from/extend-dynatrace/extend-metrics/reference/metric-ingesti...