SignalFx Developers Guide

when()

Creates a when object for use in detect() functions. The when object contains a predicate that returns a boolean value when evaluated The lasting and at_least parameters can be used to control how long and how often the predicate must be true `for the when object to return ``rue when it’s evaluated.

Syntax

when(predicate, lasting=None, at_least=1.0)

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

lasting

string

Optional: Specifies a duration that the predicate must evaluate to true before the function returns true. The indicator is s for seconds, m for minutes, and h for hours.

at_least

Decimal number

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

when(predicate, lasting=None)

  • predicate: boolean expression to indicate when this expression should evaluate to True

  • lasting : A lasting() object

Returns a when object.

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