Skip to content

sub

Input Stack:
ts2: TimeSeriesExpr
ts1: TimeSeriesExpr
Output Stack:
(ts1 - ts2): TimeSeriesExpr
 

Compute a new time series where each interval has the value (a subtractNaN b) where a and b are the corresponding intervals in the input time series.

NaN values are handled specially: if either input is NaN, it is treated as 0 for the operation. If both inputs are NaN, the result is NaN. This differs from strict floating point subtraction where any NaN input produces NaN output.

:sub 1.0 0.0 1.0 1.0 NaN
Input 1 2.0 0.0 1.0 1.0 NaN
Input 2 1.0 0.0 0.0 NaN NaN

Parameters

  • ts1: First time series or numeric value (minuend)
  • ts2: Second time series or numeric value to subtract from the first (subtrahend)

Examples

Subtracting a constant value from a time series:

BeforeAfter
name,sps,:eq
name,sps,:eq,
30e3,:sub

Subtracting two time series:

BeforeAfter
name,requestLatency,:eq,
:sum,
name,requestsPerSecond,:eq,
:max,
(,name,),:by
name,requestLatency,:eq,
:sum,
name,requestsPerSecond,:eq,
:max,
(,name,),:by,
:sub
  • :add - Add two time series
  • :fsub - Strict floating point subtraction (NaN - anything = NaN)
  • :mul - Multiply two time series
  • :div - Divide two time series
  • :neg - Negate a single time series