Skip to main content


A Workflow Engine function for basic math: addtion( +), subtraction (-), multiplication (*), division (/), and percentage (%). You can perform math functions on two fields and write the result to a destination field in either custom_info or the workflow context. The action returns true when both sides of the operation are numbers and the evaluation results in a valid number.

Because the basicMaths action can write data into and read data from the workflowContext, you can use multiple actions to perform complex operations. For example, you can calculate the sum of two fields and evaluate the result as a percentage of the third field:

( ( field1 + field3 ) / field3 ) * 100

The basicMaths action would be spread across two actions:

Action 1

  • Calculate the value of (field1 + field2).

  • Write the result to the workflowContext (e.g. workflowContext.step1Result).

Action 2

  • Calculate the percentage using (workflowContext.step1Result / field3) * 100.

  • Write the result to a custom_info field or workflowContext for subsequent actions.


The % operator in this action is NOT a modulus operator (remainder). It is used to calculate the percentage of the left hand side of the right hand side: ( ( left side / right side ) * 100 ).

This function is available as a feature of the Add-ons v2.1 download and later. See Install Moogsoft Add-ons for information on how to upgrade.

This function is available for event, alert, and Situation workflows.

Back to Workflow Engine Functions Reference.


Workflow Engine function basicMaths takes the following arguments:








An absolute value or substituted value for the left hand side of the operation.




One of + , - , * , / , %




An absolute value or substituted value for the righ hand side of the operation.




Either a custom_info or workflowContext location to store the results.


For this example, assume there is an alert enrichment that provides the total number of hosts in a specific location and you had a recipe based on that location. Also assume every alert in the situation was enriched with the same location and location_hosts number.

In the SituationMgLabeller you can extract this data and add it to the Situations custom_info using the $MAP[ ] macro:

$MAP[ $UCOUNT(source,affected_hosts) $UNIQ(custom_info.enrichment.location_hosts) $UNIQ(custom_info.enrichment.location_name, location)]

This add two values to the Situation custom_info:

"custom_info" : {
  "location" : "London",
  "affected_hosts" : 134,
  "location_hosts" : 200

In the Situation Workflow Engine you can use the basicMaths action to calculate the % affected in the location and add this to the custom_info (e,g. to allow this value to be used in re-labelling, or passed to an external system).

Set the following arguments:

  • leftSide : $(custom_info.affected_hosts)

  • operator : %

  • rightSide : $(custom_info.location_hosts

  • resultLocation : custom_info.percentAffected

The UI translates your settings to the following JSON: