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)
Solved! Go to Solution.
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.
Hello, @tibebe_m_digafe !
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!
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!
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!
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!