Warning Criteria
-
Add a New Condition.
- Click the + Add Condition button.
-
Set Overall Condition Logic.Ensure the dropdown next to If is set to All. This means the health rule will evaluate if all specified conditions are met.
-
Define Condition 1.
- Condition Name: In the text field, specify Condition 1.
- Metric Type: Select Metric Expression from the dropdown.
- Edit Expression: Click the Edit Expression button.
In the Variable Declarations section, declare the following variables:
- cpu_used: This variable is set to represent the value of K8s.container.cpu.used
- cpu_limit: This variable is set to represent the value of k8s.container.cpu.limit
In the Expression section, specify the following mathematical expression using the declared variables:
You can use the Insert Variable button to insert the required variable with the curly bracket.CODE({cpu_used}/{cpu_limit})*100This expression calculates the percentage of cpu_used relative to cpu_limit. Variables are enclosed in curly brackets {} as shown in the example provided in the UI.
This is required because we require the health to be displayed as critical when CPU used exceeds CPU Limit by 90 percent.
Specify the expression as ({cpu_used}/{cpu_limit})*100 - Comparison Operator: Set the comparison dropdown to > Specific Value.
- Threshold Value: Enter 75 in the value field. This means the condition is met when CPU utilization exceeds 75%.
-
Configure Triggering Behavior.
- Enable Trigger: Check the box for Trigger only when violation occurs.
- Time Window: Set the time window to 1 min(s).
-
Define Health Rule Violation for Pods.
- Under Health Rule will violate if the conditions above evaluate to true for:, select the radio button for a percentage of pods.
- Enter 30 in the text field next to % of the Pods in the Deployment are Warning. This means the health rule will violate if 30% or more of the pods in the deployment are in a warning state.