
Collection formula structure
Use this information to understand the syntax for writing the collection formulas easily. A collection formula is a calculation that is performed against raw SNMP data. It is a combination of functions, conditions, and standard mathematical operations.
Collection formula structure
All collection formulas must have the extension .formula. If a formula file has more than one formula, save it with the extension .formulas.
- Name of the formula
- Typically, formula names follow a dot notation that includes the following
structure:
For example:<resource_group>.<metric_name>.<units>.formula
- Environment.Temperature.Level.Celcius.formula
- Network.Outbound.Broadcast.pps.formulas
- function
- Built-in functions that can be used in the collection formula language that can perform a calculation on the metrics and return a value. See Common functions.
- when clause
- Filter condition to pick from the specified values or to compare the expression to determine the
value. It contains a set of key value
pairs.
when resource.type == 'card' && resource.vendor =='Huawei'
Note: All string values must be in single quotation marks. - resource type
- Typically, the
when
condition must specify the resource type from which to poll that is followed by other conditions. For example:when resource.type == 'interface' && number(resource.ifSpeed)>429496729
SNMP bulk get
In collection formulas, for those OIDs that return arrays of values, append
Array
as suffix. For
example:nqaJitterStatsAvgJitterDS.octets = average(value(NQA_MIB.nqaJitterStatsAvgJitterDSArray)) when resource.vendor == 'Huawei'
Where,
NQA_MIB.nqaJitterStatsAvgJitterDS
is the OID. When bulk get is used on the OID,
then use the suffix Array
as
NQA_MIB.nqaJitterStatsAvgJitterDSArray
. - The expression,
value(NQA_MIB.nqaJitterStatsAvgJitterDSArray)
returns an array of values. - To access the first element in the list, use
value(NQA_MIB.nqaJitterStatsAvgJitterDSArray)[0]
. - You can also use more advanced JavaScript array methods such as
.reduce()
can be used onJava.from(value(NQA_MIB.nqaJitterStatsAvgJitterDSArray))
. - Predefined functions such as
max
,min
,sum
,count
, andaverage
can also be used with these arrays.
- CPU.Utilization.Percent.formula
CPU.Utilization.Percent = value(CISCO_PROCESS_MIB.cpmCPUTotal5minRev) when resource.type == 'cpu' && resource.vendor =='Cisco'
- Network.Inbound.Broadcast.pps.formulas
Network.Inbound.Broadcast.pps = positive(delta(IF_MIB.ifHCInBroadcastPkts))/duration(IF_MIB.ifHCInBroadcastPkts)*100 when resource.type == 'interface' && number(resource.ifSpeed)>4294967295 Network.Inbound.Broadcast.pps = positive(delta(IF_MIB.ifInBroadcastPkts))/duration(IF_MIB.ifInBroadcastPkts)*100 when resource.type == 'interface' && number(resource.ifSpeed)<4294967295