02 Sep 2024 12:10 PM - last edited on 03 Sep 2024 07:16 AM by MaciejNeumann
Hi all,
I'm making a prometheus extension where metrics named with the id of the producer thread as in the code example. Right now each thread generates a separate dynatrace metric, but I would prefer the thread id as a dimension and only one metric named myapp.Smscntr. Is there any solution to this?
My current code:
prometheus:
- group: myapp metrics 0
interval:
minutes: 1
featureSet: all
dimensions:
- key: myapp
value: const:myapp
subgroups:
- subgroup: myapp global gauge
dimensions:
- key: global_gauges
value: const:global_gauges
metrics:
- key: myapp.Smscntr_Thread_0
value: metric:Smscntr_Thread:0
type: gauge
featureSet: all
- key: myapp.Smscntr_Thread_1
value: metric:Smscntr_Thread:1
type: gauge
featureSet: all
- key: myapp.Smscntr_Thread_2
value: metric:Smscntr_Thread:2
type: gauge
featureSet: all
Thanks,
Peter
02 Sep 2024 02:30 PM
Any chance you can modify your prometheus source? If your source will be like:
Smscntr_Thread{thread="0"} value_0
Smscntr_Thread{thread="1"} value_1
Smscntr_Thread{thread="2"} value_2
then you can just use:
value: metric:Smscntr_Thread
and you will end with one metric with 3 dimensions.
03 Sep 2024 12:41 PM
Hello @rastislav_danis ,
Thanks for the suggestion. Unfortunately changing the source is not possible.
03 Sep 2024 01:40 PM
Then i'm afraid it's not easily possible. There is no ootb option how to map 3 different prometheus metric endpoints into 1 dynatrace metric via prometheus v2 extension. You can use f.e. python v2 extension to achieve this.