SignalFx Developers Guide

when()

Creates a when object for use in a detect() function. The when object contains a predicate that returns a boolean value when evaluated The <lasting_value> and <at_least_value> values control how long and how often the predicate must be true for the when object to return true when it’s evaluated.

Syntax

when(predicate [,lasting=duration][,at_least=percentage])

Table 1. Parameter definitions
Parameter Type Description

predicate

string

Expression that evaluates to true or false. The function returns the result of this expression. The expression is composed of the following:

  • Metrics, dimensions, and properties in the input stream

  • Variables defined in the SignalFlow program

  • Comparison operators <,>,=,!=

  • Functions

  • logical operators and, or, not

duration

Numeric string followed by a time indicator, or a lasting() function. Default is None.

Optional: Specifies a duration that the predicate must evaluate to true before the function returns true.
Durations are specified as a number followed by a single character:

  • s: seconds

  • m: minutes

  • h: hours

  • d: days

The default is None.

at_least

Decimal,
0.0 ≤ at_least ≤ 1.0.
Default is 1.0.

Optional: Specifies the percentage of lasting that predicate must be true before the function returns true. Allows and, or, and not operators. For example, .95 represents 95%.

Examples

1
2
3
4
5
6
7
8
9
#When cpu.utilization is greater than 50
when(data('cpu.utilization') > 50)

#When the stddev of memory.utilization is greater than .2 for 50% of 5 minutes
mem_stddev = data('memory.utilization').stddev()
when(mem_stddev > .2, '5m', .5)

#Combine whens to make a complex when expression
when(data('cpu.utilization') > 50) and not (data('memory.utilization') > 70, '5m', .7)

© Copyright 2019 SignalFx.

Third-party license information