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

Metrics - custom based on built-in metrics

Hello,

 

Any options to create a "custom" metric via API based on built-in metrics?

I would like to have k8s pod CPU usage percentage as  CPU request (built-in) vs CPU limit (built-in).

The new "custom" metric will be used in custom events for alerting. 

 

I am avoiding having to "write" a plugin or external tool to calculate and push the metric values (API)

 

Thanks. Tibebe

 

3 REPLIES 3

ChadTurner
DynaMight Guru
DynaMight Guru

in the new metrics explorer they will be allowing you to calculate values. I dont think it is GA yet, but its on its way. Just keep in mind, this wont trigger an alert. If you want calculated alerts like CPU Total minus CPU Used for the value of CPU Available Less then 20% raise an alert.... you would need to put in a RFE for that. 

-Chad

PedroDeodato
Guide

Hello, @tibebe_m_digafe !

 

If you want to setup a custom metric just for alerting purposes, maybe a Custom Alert with Metric Expressions will suit your needs!

Basically, when defining the Custom Alert, instead of selecting a built-in metric, switch to the "Code" tab (available on version 1.222) and write the expression that represents the metric you want!

PedroDeodato_0-1628154983418.png

 

After that, you just have to define the "Monitoring strategy" (static threshold or auto-adaptive baseline) to set when should the alert be triggered, and that's about it!

PedroDeodato_1-1628155028324.png

 

 

 

To ease the process, the best way (in my opinion, of course) to get the right "Code" expression is to head down to "Data Explorer", select the metric you want on the "Build tab". After setting it up as desired, switch to the "Code" tab and copy the code that Dynatrace put there automatically!

 

PedroDeodato_2-1628155157158.pngPedroDeodato_3-1628155171094.png

After that, paste it to the Metric Expression you're trying to calculate on the Custom Alert setup.

You repeat this process for each metric you want, using the pasted codes as variables, and building the expression you need around them!

 

Quick heads-up: as stated on the documentation, "Each operand must be wrapped in parentheses (). You can also use brackets to enforce precedence."

So, on your specific use case, you might want to try something like: (CPU Limit metric)-(CPU Request metric)

 

Hope this helps!

Best regards, Pedro Deodato

Thanks much Pedro,

 

Metric expressions make life easier. I hope enhancements to it down the road will make the feature even more valuable. 

 

Thanks. Tibebe