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

How to add metrics, some of which may be null?

bryceamacker
Frequent Guest

Hello, I am trying to build some queries that will add multiple metrics together for single value visualizations. The issue is some of these metrics could potentially be empty but are expected to eventually have data. I'm having trouble finding a way to ignore or set defaults to those empty metrics from the total addition aggregation, which breaks the entire query.

 

As an example, assume you are consuming DDU metrics, but not DDU logs (at the moment, but plan to). If I wanted to have a visualization of total DDU consumption, I'd try:

 

 

 

(builtin:billing.ddu.log.total)+(builtin:billing.ddu.metrics.total):auto:sort(value(sum,descending))

 

 

 

And due to ddu.log.total (at the moment) being empty, the entire query with the error out with:

 

"Result of metric expression was empty because one of the inputs was empty. `(builtin:billing.ddu.log.total)` was empty but `(builtin:billing.ddu.metrics.total):auto:sort(value(sum,descending))` had 1 dimension tuples."

 
I have tried using the default transformation, but I get this error when adding it to any part of the query:
"Illegal transform operator: Usage of default operator is only supported for resolutions other than `Inf`."
4 REPLIES 4

AgniLanka
Helper

try (builtin:billing.ddu.metrics.total):default(0)

Unfortunately I get the error:

"Illegal transform operator: Usage of default operator is only supported for resolutions other than `Inf`."

bryceamacker_0-1641487488728.png

 

uros_djukic1
Dynatrace Advisor
Dynatrace Advisor

Hi @bryceamacker ,
Please try rather this way : 
(builtin:billing.ddu.metrics.total:splitBy():sum:auto:sort(value(sum,descending)))+(builtin:billing.ddu.log.total:splitBy():sum:auto:sort(value(sum,descending)))

given that splitby() allow to rid of dimensions and return accurate value from targeted metric.
Thanks

Hi, I am trying to us splitby(), but still get the empty warning which does not allow me to proceed this calculation 

 

calc:apps.web._AAAA:splitBy():count:auto:sort(value(avg,descending)) - (calc:apps.web._BBBB:splitBy():count:auto:sort(value(avg,descending)))   metric BBBB is the one which has "no data" at some point of time, but I want to leave it as 0 if there is no data

Featured Posts