cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom metrics - Weighted Median Response Time

Dimitris_Pin
Observer

Hello,

I was asked from a client to add to a dash a custom metric for some key requests i have. Specifically i was asked to create this metric:

Weighted Median Response Time = (Key_request_X Median Response Time * Key_request_X Count + Key_request_Y Median Response Time * Key_request_Y Count)/ (Key_request_X Request Count + Key_request_Y Count)

Is there a way to do this and actually show it in a dashboard?

Thank you in advance

10 REPLIES 10

Hi @Dimitris_Pin ,

I think you can get it using these two base queries:

builtin:service.keyRequest.response.server:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"keyrequest~")"))))):median

builtin:service.keyRequest.count.total:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"keyrequest~")")))))

and then combine them with mathematic operators:

Ex:

((builtin:service.keyRequest.response.server:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"getConfiguration~")"))))):median) * (builtin:service.keyRequest.count.total:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"getConfiguration~")")))))) ) + ...... 

 

Hope it helps.

Regards,

Elena.

 

jaume_reverte
Dynatrace Advisor
Dynatrace Advisor

Hello Dimitris, 

You should be able to create a tile using Dataexplorer with the following Advanced mode query: 

((
builtin:service.keyRequest.count.client:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"Key_request_X~")"))))):splitBy("dt.entity.service_method"):avg:default(0)
*
builtin:service.keyRequest.response.time:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"Key_request_X~")"))))):splitBy("dt.entity.service_method"):avg:default(0)
+
builtin:service.keyRequest.count.client:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"Key_request_Y~")"))))):splitBy("dt.entity.service_method"):avg:default(0)
*
builtin:service.keyRequest.response.time:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"Key_request_Y~")"))))):splitBy("dt.entity.service_method"):avg:default(0)
)
/
(
builtin:service.keyRequest.count.client:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"Key_request_X~")"))))):splitBy("dt.entity.service_method"):avg:default(0)
+
builtin:service.keyRequest.count.client:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"Key_request_Y~")"))))):splitBy("dt.entity.service_method"):avg:default(0)
))  

 Hope you a good monitoring! 

Hope you a good monitoring!
Jaume Reverte

Dimitris_Pin
Observer

Thank you @erh_inetum and @jaume_reverte for your answers. I tried both you answers and a few more on my own. Code seems to work just fine with no errors, but when i run the query i get no data. When i run the metrics individually i get the output im expecting. Any insights?

Welcome,  Dimitris.

Do you have data for all metrics in the selected timeframe? If for any metric hasn't data maybe It was the reason for which you don't get data.

To avoid it, use default(0) fold.

 

Hope it helps.

Regards,

Elena

Thank you @erh_inetum. Yes i have data because for each individual metric of the key requests i see data. The problem is when i try to combine them. I used the default(0) as well.

Thanks,

Dimitris

Hi Dimitris,

If you have data in the whole timeframe for the two webrequest is not necessary you use fold transformation.

Have you be sure to put the brackets in the correct place?

It works and it returns data:

((
(builtin:service.keyRequest.response.server:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"keyrequestA~")"))))):median)
*
(builtin:service.keyRequest.count.total:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"keyrequestA~")"))))))
)
+
(
(builtin:service.keyRequest.response.server:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"keyrequestB~")"))))):median)
*
(builtin:service.keyRequest.count.total:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"keyrequestB~")"))))))
))
/
(
(builtin:service.keyRequest.count.total:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"keyrequestA~")"))))))
+
(builtin:service.keyRequest.count.total:filter(and(or(in("dt.entity.service_method",entitySelector("type(service_method),entityName.equals(~"keyrequestB~")"))))))
)

Hope it helps.

Regards,

Elena.

Hello Elena (@erh_inetum) and Jaume (@jaume_reverte ) ,

I fixed the issue. It had to do with dimensions not being the same. I used the merge method to see data in my explorer. Here i will attach my code so that people can use it for future reference, if anyone comes across the same problem:

((
(
builtin:service.keyRequest.response.time:filter(and(in("dt.entity.service_method",entitySelector("type(service_method),entityId(~"Request_X~")")))):merge("dt.entity.service_method"):median
*
builtin:service.keyRequest.count.total:filter(and(in("dt.entity.service_method",entitySelector("type(service_method),entityId(~"Request_X~")")))):merge("dt.entity.service_method"):sum
)
+
(
builtin:service.keyRequest.response.time:filter(and(in("dt.entity.service_method",entitySelector("type(service_method),entityId(~"Request_Y~")")))):merge("dt.entity.service_method"):median
*
builtin:service.keyRequest.count.total:filter(and(in("dt.entity.service_method",entitySelector("type(service_method),entityId(~"Request_Y~")")))):merge("dt.entity.service_method"):sum
)
)

/
(
builtin:service.keyRequest.count.total:filter(and(in("dt.entity.service_method",entitySelector("type(service_method),entityId(~"Request_X~")")))):merge("dt.entity.service_method"):sum
+
builtin:service.keyRequest.count.total:filter(and(in("dt.entity.service_method",entitySelector("type(service_method),entityId(~"Request_Y~")")))):merge("dt.entity.service_method"):sum
) )

Dimitris_Pin
Observer

Hello @erh_inetum and @jaume_reverte . One more quick question regarding the matter. Is there any way to get the absolute value of the metric we created above? cause i cant seem to find any function for that.

Thank you!

Hi Dimitris,

I think it's not possible for Data Explorer but with DQL you can do that using abs function

Regards,

Elena.

 

That's what i was afraid of. Unfortunately my client is on the Managed Enviroment, so there is no fix there.

Really appreciate your answer. Have a great day!

Featured Posts