Information

This site will undergo a brief period of maintenance on Friday, 18 December at 12:30 AM Central/12:00 PM IST. During a 30 minute window, site availability may be intermittent.

Examples of formulas and parameters in custom Optimizer rules


You can define a formula to generate alerts and recommendations from a custom Optimizer rule. And, you can define parameters to be used in the formula.

Warning

Adding custom Optimizer rules based on formulas is intended for advanced users only.



Examples of formulas

The following table contains some examples of formulas that you can add to the Formula field in the Condition section of a custom Optimizer rule.

Goal

Example of formula

To generate an alert on overprovisioned datastores based on metric values (DSTORE_PROVISIONED is greater than DSTORE_SIZE)

alerted = (DSTORE_PROVISIONED.value > DSTORE_SIZE.value);

To know if data for an indicator/metric (IND_DAYS_TO_SATURATION) is available

if (IND_DAYS_TO_SATURATION) { ... }

To get an indicator (IND_DAYS_TO_SATURATION) value

IND_DAYS_TO_SATURATION.value

To get a specific subresource value, for example CPU

IND_DAYS_TO_SATURATION.subresource("CPU").value;

To know if data for a certain subresource is available, for example CPU

if (IND_DAYS_TO_SATURATION.hasSubresource("CPU")) { ... }

To set a value or threshold in the output

point.value0 = some_value; point.threshold0 = a_threshold; ...;
point.value20 = some_value; point.threshold20 = a_threshold;

To add a resource to an alerted subresource, for example CPU

point.addAlertedResource("CPU");

To 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

customrule_formula.png

Examples of parameters

Parameters must be inserted as per the following syntax:

<name of parameter> | <description> | <threshold value> | <type>

Where <type> can be a number or a string.

To add more than one parameter to your custom rule, separate them with a newline character (press Enter) in the Parameters section. You can add as many parameters as you like.

Parameters are commonly used to define new thresholds that can be used in formulas.

The following table contains some examples of parameters that you can add to the Parameters field in the Condition section of a custom Optimizer rule.

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

customrule_param.png

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

To the following thresholds in the formula:

  • dts_th_crit|Days to saturation critical threshold|7|number
  • dts_th_warn|Days to saturation warning threshold|30|number

var res = false;
var dts_th = Math.max(dts_th_crit, dts_th_warn);
if (IND_DAYS_TO_SATURATION.value <= dts_th)
{
res = true;
}

Screenshot with sample data

customrule_parameters.png

Example of recommendation text in a custom Optimizer rule

Example of recommendation text or description using a Velocity template

The following code block illustrates an example of a Velocity template description that you can add to the Recommendation text field in the custom Optimizer rule. This field is displayed only after you select an option in the Recommendation type list.

#if ( $point.value0>0)  Forecasted saturation in $numberFormatter.format($point.value0) days. #else Some resources are already saturated. #end
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

Screenshot with sample data

customrule_reco.png

You can use formatting functions that the Velocity template provides in the Recommendation text field. The following table illustrates some of these formatting functions.

Structure of a recommendation output

A recommendation output is structured as follows (split into 2 lines only for illustration purposes):

alert.cond.1.rule.recomm.vtl = 
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:

alert.cond.1.severity = 3

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC TrueSight Capacity Optimization 20.02