LogicMonitor + Catchpoint: Enter the New Era of Autonomous IT

Learn more

Complex datapoints enable you to create new, calculated values derived from existing normal or complex datapoints. Unlike normal datapoints, which capture raw data directly from monitored systems, complex datapoints perform calculations using those collected values to generate metrics that can be used more effectively in dashboards, reports, and alerts.

LogicMonitor supports the following methods for calculating complex datapoints:

  • Standard complex datapoints—Use expression syntax to calculate new values from datapoints, resource properties, or numbers.
    For example, the SNMP interface MIB provides an OID that reports the inbound octets on an interface (InOctets). This can be converted to the value carried by the InOctet datapoint to Mbps using the following expression: InOctets*8/1000/1000
  • Groovy complex datapoints—Use Groovy scripts to perform advanced processing on raw data when expressions are not sufficient.
    In a Groovy complex datapoint, you have access to the raw data payload, but not the actual datapoints (for example, those calculated as a “counter” or “derive”). In addition, you can use Groovy for calculations based on both resource and instance properties. Typically, you can use a Groovy complex datapoint for manipulating data in a way that cannot be achieved with a standard complex datapoint.

Together, these options provide flexibility—enabling everything from basic conversions to complex custom logic—so you can tailor monitoring to reflect the metrics most important to your environment.

Recommendation: Use a Groovy complex datapoint sparingly, only when you require advanced processing beyond the expression syntax provided by a standard complex datapoint.

Expression Syntax for Standard Complex Datapoint

When constructing standard complex datapoints in LogicMonitor, you use datapoint expression syntax to define how new values are calculated from existing datapoints, resource properties, or numerical constants. These expressions can perform arithmetic, logical, and conditional operations, and can include mathematical functions or constants.

Recommendation: Datapoint expressions can be written in Infix or RPN (Reverse Polish Notation), similar to the following:

  • Infix—(sendpkts-recdpkts)/sentpkts*100
  • RPN—sendpkts,recdpkts,-,sentpkts,/,100,*

All following examples use Infix notation.

Expression Operands

You can use the following kinds of operands: 

  • Datapoint names
  • Resource property names
  • Arbitrary numbers

The following example uses numbers and datapoint names to calculate the percentage of inbound packets discarded on a particular interface:
100 * InDiscards / (InBroadcastPkts + InUcastPkts + InMulticastPkts + InDiscards) * ##BandwidthLimit##

Expression Operators

Datapoint expressions support a variety of operators for performing calculations and evaluations. These include arithmetic, bitwise, and logical operators, enabling you to build formulas that manipulate and compare datapoint values.

The following table summarizes the available operator types and their functions:

CategorySyntaxExample
Arithmetic Operators+ Addition2 + 2 = 4
- Subtraction3 - 2 = 1
* Multiplication2 * 3 = 6
/ Division4 / 2 = 2
% Modulus4 % 2 = 0
Bitwise Operatorsx & y bitwise and
• 1010 & 1100 = 1000
x | ybitwise or
• 1010 | 1100 = 1110
Logical Operators&&(expression1,expression2)
or
and(expression1,expression2)
logical and: evaluates as true if both expression1 and expression2 are true (non-zero)
• and(2+2,1+1) = true
• and(2+2,2-2) = false
||(expression1,expression2)
or
or(expression1,expression2)
logical or: evaluates as true if either expression1 or expression2 is true (non-zero)
• or(2+2,1-1) = true
• or(2-2,1-1) = false

Note: The Boolean data type is not supported in datapoint expressions. Instead, any non-zero value is treated as TRUE and zero is treated as FALSE.

In the case where both operands are non-zero,
&& / and returns “1”. In the case where either operand is non-zero,
|| / or returns “1”.

Expression Functions

Datapoint expressions support a range of built-in functions that extend their calculation and evaluation capabilities beyond basic operators. These include conditional, comparison, and mathematical functions, as well as constants for use in formulas.

The following table outlines the available function types and their purposes:

CategorySyntaxExample
Conditional Syntaxif(x,y,z) if expression x evaluates as true, return y; otherwise return z
if(0, 1, 2) = 2
if(1, 1, 2) = 1
Comparison Functions


Note: Comparison functions are typically used within a conditional (if) statement.
lt(x,y)evaluates as true if x < y
lt(1, 2) = 1
le(x,y)evaluates as true if x <= y
le(3, 1) = 0
gt(x,y)evaluates as true if x > y
gt(2, 1) = 1
ge(x,y)evaluates as true if x >= y
ge(4, 1) = 1
eq(x,y)evaluates as true if x == y
eq(4, 1) = 0
limit(x,y,z) returns x if x is between the inclusive bounds of y and z; otherwise NaN
limit(1, 2, 3) = NaN
limit(4, 4, 7) = 4
in(i[, j, …, n], z) evaluates as true (1) if z is present in the list of possible values; otherwise returns false (0)
in(DatapointOne, DatapointTwo, DatapointThree, value) = 1 when any datapoint currently return “value”
in(value1, value2, value3, DatapointOne) = 1 when DatapointOne currently returns any of the listed values
max(x,y)returns the larger of x and y
max(1,2) = 2
min(x,y)returns the smaller of x and y
min(1,2) = 1
un(x)evaluates as true (1) if x is unknown (not a number)
un(1) = 0
Mathematical Functionsround(x)rounds the value x to an integer value
round(1.89) = 2
floor(x)returns the previous smallest following integer of x
floor(2.78) = 2
ceil(x)returns the previous largest following integer of x
ceil(2.78) = 3
abs(x)returns the absolute value of x
abs(-3) = 3
log(x)returns the natural logarithm of x
exp(x)returns the natural exponential of x (ex)
pow(x,y)returns the result of raising x to the y power (xy)
sqrt(x)returns the square root of x
sin(x)returns the sine of x
cos(x)returns the cosine of x
Constantsunkn()returns NaN (not a number)
pi()returns the value of pi
e()returns the value of Euler’s number (e)
inf()returns the value of positive infinity
neginf()returns the value of negative infinity
random()returns a random number between 0 and 1

Special Cases for Standard Complex Datapoints

In some cases, datapoint expressions require special handling for negative or unknown (NaN) values to ensure accurate calculations and display results.

The following table summarizes these special cases and how LogicMonitor processes them:

CategoryDescriptionExample
Negative ValuesDatapoint expressions cannot begin with a negative sign. Use subtraction from zero to represent negative values.Use 0-2 instead of -2.
Unknown Values (NaN)Unknown values—such as missing, non-numeric, or infinite data—can be handled within expressions using conditional logic.if(un(DatapointOne),0,DatapointOne) returns 0 if the datapoint is unknown; otherwise, returns its value.
Conditional Handling with NaNYou can return “No Data” (NaN) conditionally using the unkn() function.if(lt(DatapointTwo,5),unkn(),DatapointTwo) returns “No Data” if the value is less than 5.
NaN in Logical OperationsLogical expressions (and, or) always evaluate to 0 or 1, even when operands are NaN. To avoid false results, check for NaN before evaluation.if(or(un(Datapoint1),un(Datapoint2)),unkn(),<expression>) ensures valid input before running the expression.
NaN Behavior by Operator / Function TypeArithmetic Operators
+, -, *, /, %
Returns NaN
Bitwise Operators
&, |
Returns non-NaN
Logical Operators
and, or, xor
Returns 0 or 1
Conditional Expr
if(x,y,z) and x is NaN
Returns z
Comparison Func
lt, le, gt, ge, eq, in
Returns 0 or 1
Mathematical Func
min, max, sin, cos…
Returns NaN

Expression Syntax for Groovy Complex Datapoints

When you need to do additional processing not possible with datapoint expressions, you can turn to Groovy scripting for more full-featured datapoint calculations. Groovy complex datapoints use a Groovy script to process the raw collected data. In a Groovy complex datapoint, you have access to the raw data payload, but not the actual datapoints (for example, those calculated as a “counter” or “derive”). In addition, you can use Groovy for calculations based on both resource and instance properties.

Groovy complex datapoints are typically used when data manipulation cannot be achieved with a standard complex datapoint. They are also useful when the module does not already use an embedded Groovy script for data collection, or when it does but is an official LogicMonitor module. In these cases, a Groovy complex datapoint provides a flexible way to perform advanced data processing and customization.

When you use Groovy to construct a complex datapoint, the Collector pre-populates Groovy variables with the raw data collected from normal datapoints. The type and syntax of these objects varies based on the collection method used by the DataSource.

Note: Use a Groovy complex datapoint sparingly, only when you require advanced processing beyond the expression syntax provided by a standard complex datapoint.

The following table lists the variable names available for each collection method and demonstrates how Groovy complex datapoints can use them to process and manipulate raw monitoring data. Each example highlights a common use case and the type of Groovy logic applied to return meaningful, calculated values:

Collection TypeGroovy VariablesExample
SNMPoutput—The snmp payload is represented as an array, with each oid/response pair represented as an element separated by =. Calculate total octets by summing inbound and outbound values:

// iterate through output array
output.each
{ line ->
    (oid, value) = line.toString().split('=');
    // get inOctet and outOctet values
    if (oid.startsWith(".1.3.6.1.2.1.31.1.1.1.6"))
    {
        totalInOctets = value.toFloat();
    }
    else if (oid.startsWith(".1.3.6.1.2.1.31.1.1.1.10"))
    {
        totalOutOctets = value.toFloat();
    }
}
// sum the values and return
totalOctets = totalInOctets + totalOutOctets;
return(totalOctets);
HTTPstatus—The status code of the http client (1–5), with 5 being connection failed

responseTime—Response time in milliseconds

output—Entire HTTP response including header and body

body—HTTP body only
Normalize and interpret HTTP status results:

if (status < 2)
{
    myStatus = 5;
}
else
{
    myStatus = 10;
}
return(myStatus);
WMIoutput—A map containing each of all the properties of the specified WMI class with the property names (in upper case) as keys. Retrieve a specific property value from a WMI class:

rawDate=output["LOCALDATETIME"];
return(rawDate);
JMXoutput—A map containing each of the specified mbeans and their raw values. Calculate elapsed time since a returned date string:

rawDate = output["solr/##WILDVALUE2##:type=/replication,id=org.apache.solr.handler.ReplicationHandler:replicationFailedAt"]
fd = Date.parse('EEE MMM dd HH:mm:ss z yyyy', rawDate)
today = new Date()
return((today.time - fd.time)/1000)

Note: Groovy complex datapoints reference the raw data exactly as it is collected (that is, as a “gauge” datapoint), rather than calculated as a rate such as “counter” or “derive” datapoint. After you process your data in Groovy, must use the return(); method to pass the calculated value back to the Collector for storage.

Resource and Instance Properties in Groovy Complex Datapoints

You can use the resource or instance properties that you collect within a Groovy complex datapoint.

The following tables explains how the resource or instance properties can be referenced within Groovy:

PropertyRetrieves
hostProps.get("auto.PropertyName")Resource property
instanceProps.get("auto.PropertyName")Instance property
taskProps.get("auto.PropertyName")Property of either type

For more information and examples, see Embedded Groovy Scripting.

Configuring a Complex Datapoint

Note: The following steps outline the procedure for configuring the common steps for a datapoint. For specific steps related to each collection method, see the applicable documentation for each collection method.

  1. In LogicMonitor, navigate to Modules.
  2. Select My Module Toolbox, and then either create a new DataSource or navigate to the DataSource you want to create a complex datapoint for.
    For more information, see DataSources Configuration or Modules Management.
  3. Configure or modify the settings as needed for the module.
    For more information, see DataSources Configuration.
  4. In the Datapoints settings, select Add a Complex Datapoint, and do the following:
  5. In the Name field, enter a name for the datapoint.
  6. In the Description field, enter a description as needed.
  7. From the Method dropdown, select one of the following methods you want to use to calculate the datapoint:
    • To calculate a standard complex datapoint, select “Use an expression (infix or rpn) to calculate the value”, and then enter the expression for calculation in the Expression field.
      For more information on the expressions you can use to calculate a standard complex datapoint, see Expression Syntax for Standard Complex Datapoints.
    • To calculate a groovy complex datapoint, select “Use a groovy script to calculate the value”, and then enter the groovy script in the Groovy source code field.
      For more information on groovy scripts syntax you can use to calculate a standard complex datapoint, see Expression Syntax for Groovy Complex Datapoints.
  8. (Optional) To display readable status values for a datapoint, select Add Status Display Name, and then do the following:
    1. In the Status Value field, enter the number value returned by the datapoint. 
    2. From the Operator dropdown menu, select how you want the value to apply:
      • When the value is higher than the specified value, select “(>) Greater than.”
      • When the value reached or exceeds the specified value, select “(>=) Greater than or equal to.”
      • When the value is lower than the specified value, select “(<) Less than.”
      • When the value is at or below the specified value, select “(<=) Less than or equal to.”
      • When the value exactly matches the specified value, select “(=) Equal to.”
      • To all values except the specified value, select “(!=) Not equal to.”
    3. In the Display Name field, enter the corresponding status text (for example, 3 = Non-operational).
    4. Select Apply to save. 
    5. Configure the Alert Thresholds settings as necessary.
      For more information, see Alert Threshold Overview.
    6. Select blue save icon to save the datapoint.
  9. Configure any additional settings for the DataSource, and then select Save.

14-day access to the full LogicMonitor platform