23 Oct 2024 02:40 PM
Hello,
Text metrics seem not working.
Context: I develop python extensions on my machine, build and upload to Dynatrace. Then the extensions are running on a cloud cluster.
I send 2 metrics :
# __main__.py file
self.report_metric("my_metric_text", "OK")
self.report_metric("my_metric_num", 1)
I run the simulation with the SDK, all is ok :
$ dt-sdk run my_extension
...
send_metric: my_metric_text gauge,OK
send_metric: my_metric_num gauge,1
Sent 2 metric lines to EEC: [MintResponse(lines_ok=2, lines_invalid=0, error=None, warnings=None)]
...
I run the build and the upload, also no error.
Then, when the extension run on the target environnement, I get this error from the log :
_send_metrics: 1 invalid metric lines found
When I check the metrics data, I only saw the numerical metric. So this is the text metric that is considered as 'invalid'.
I checked the documentation, the 'value' parameter can be a text :
value: float | str | int | SummaryStat
I am missing something ?
I am very concerned about the difference between the local run (with the dt-sdk run command) and the 'true' run in production.
We are at the end of our migration from extension 1.0 to 2.0 and we run all the new extension on local, to not impact production metrics.
Solved! Go to Solution.
23 Oct 2024 04:02 PM
@MathieuB there is no such thing as string metrics in Dynatrace. It accepts the SummaryStat which is a structure to allow sending min/max/sum/count in a single call. It's not a string.
The dt-sdk run does not include EEC which does the metric value validation, that's why you see different outcomes between the simulator and real deployment.
23 Oct 2024 04:27 PM
@Julius_Loman thanks for the explanation.
On Extension 1.0, we had "state metric", which allow to have "OK/KO" metric (with the state_metric method).
So you are saying that with EF2 we lost the state metric ?
If so, I have a huge rework on all my extension...
It's a shame that the simulator is useless regarding the metric.
23 Oct 2024 04:36 PM
No... Actually the state metric was a little bit "fake". It used a dimension for reporting the status and a constant value of 1.
So the metric was reported with either status=OK or status=KO dimension in your example. So you just need to send a dummy metric with the value of 1 with the dimension value of your choice.
The simulator is not useless. Just this would require an EEC running along with the simulator. @michal_nalezin maybe a product idea for you? Simulator is mostly about being able to collect and process the data. It does not valide the results you are sending.
23 Oct 2024 04:47 PM
So all my work was a fake with EF1 😂 (please don't tell my compagny)
Thanks a lot for your time, I will try to play with the dimensions to retrieve the behaviour I use with EF1.
Regards,
Mathieu
23 Oct 2024 05:46 PM
Your work was not fake, the way how DT did that in extension V1 was sort of a hack 😜
You should be able to get the exactly same behaviour with Extension V2, just use the same dimensions and values.
23 Oct 2024 04:47 PM
in Extensions v2 as the following figure
1st argument for the metrics name
2nd argument for the metric value it should be numeric and cannot be string
3rd argument is array of dimensions for the current reported data point
try to imagine that the data points for getting percentage of cpu usage is
7:45:00pm = 98
7:46:00pm = 95
7:47:00pm = 'fully_utilized'
how dynatrace going to give you average value over last 5 minutes ?!!