Adding a custom Optimizer rule
Adding a custom rule
- Click Administration > OPTIMIZER > Rules.
- In the Optimizer Rules page, click Add new rule.
In the New Optimizer rule page, enter values and make appropriate selections for the following properties:
Properties marked with ✅️ are available only while building a rule in Advanced mode. To switch (toggle) to Advanced mode, click Advanced.
- Click Save.
The rule is saved and enabled by default. The rule is listed in the Optimizer rules table. The rule is triggered to run based on the Optimizer task that is associated with the rule.
Examples of formulas
The following table contains some examples of formulas that you can add to the Formula field. You can use the format as Apache Velocity template. For information on the Apache Velocity template, Apache Velocity template.
Goal | Example of formula |
---|---|
Generate an alert on overprovisioned datastores based on metric values (DSTORE_PROVISIONED is greater than DSTORE_SIZE) | alerted = (DSTORE_PROVISIONED.value > DSTORE_SIZE.value); |
Know if data for an indicator/metric (IND_DAYS_TO_SATURATION) is available | if (IND_DAYS_TO_SATURATION) { ... } |
Get an indicator (IND_DAYS_TO_SATURATION) value | IND_DAYS_TO_SATURATION.value |
Get a specific subresource value, for example CPU | IND_DAYS_TO_SATURATION.subresource("CPU").value; |
Know if data for a certain subresource is available, for example CPU | if (IND_DAYS_TO_SATURATION.hasSubresource("CPU")) { ... } |
Set a value or threshold in the output | point.value0 = some_value; point.threshold0 = a_threshold; ...; point.value20 = some_value; point.threshold20 = a_threshold; |
Add a metric (resource) to an alerted subresource, for example CPU | point.addAlertedResource("CPU"); |
Generate an alert when the days to saturation for CPU, memory, or storage is more than the threshold value | var res = false; if(Math.round(IND_DAYS_TO_SATURATION.value)<=30) { if(IND_DAYS_TO_SATURATION.hasSubresource("CPU") && IND_DAYS_TO_SATURATION.subresource("CPU").value<30) { res = true; } if(IND_DAYS_TO_SATURATION.hasSubresource("MEMORY") && IND_DAYS_TO_SATURATION.subresource("MEMORY").value<30) { res = true; } if(IND_DAYS_TO_SATURATION.hasSubresource("STORAGE") && IND_DAYS_TO_SATURATION.subresource("STORAGE").value<30) { res = true; } } alerted = res; |
Screenshot with sample data
Examples of parameters
Define parameters as per the following syntax:
Where <type> can be a number or a string.
Parameters are used to add new thresholds that can be used in formulas. You can define multiple parameters by separating them with a newline character (press Enter).
The following table contains some examples of parameters that you can add to the Parameters field.
Goal | Parameter definition |
---|---|
To create a threshold: Days to saturation – Critical threshold, set to a value of 7 (days) | dts_th_crit|Days to saturation critical threshold|7|number |
To create a threshold: Days to saturation – Warning threshold, set to a value of 30 (days) | dts_th_warn|Days to saturation warning threshold|30|number |
Screenshot with sample data
Example of using parameters in formulas
The following table contains some examples of parameters that are used in a formula in a custom Optimizer rule.
Goal | Parameter definition |
---|---|
Use the following thresholds in the formula:
| var res = false; |
Screenshot with sample data
Example of recommendation text or description
The following code block contains an example of a Velocity template description that you can add to the Recommendation text field in the custom Optimizer rule.
Details:
#if ($point.alertedResources.contains('CPU'))
#if ($point.value1>0) CPU will saturate in $numberFormatter.format($point.value1) days.
#else CPU exhausted.
#end
#end
#if ($point.alertedResources.contains('MEMORY'))
#if ($point.value2>0) Memory will saturate in $numberFormatter.format($point.value2) days.
#else Memory exhausted.
#end
#end
#if ($point.alertedResources.contains('STORAGE'))
#if ($point.value3>0) Storage will saturate in $numberFormatter.format($point.value3) days.
#else Storage exhausted.
#end
#end
You can use formatting functions that the Velocity template provides in the Recommendation text field. The following table describes some of these formatting functions.
Structure of a recommendation output
A recommendation output is structured as follows:
Allocate more $stringFormatter.formatList($point.alertedResources)
Setting a status for alerts in the recommendation output
To set a critical status for an alert, you must set the severity as per the ALERT_STATUS table.
For example, to generate a Critical alert whose ID is 3, the structure is as follows: