.conf25 registration is now open!Register today

 const()

Creates a stream of constant-value MTS.

 Syntax

const(value=constant_value, key=key_maps, timeseries=timeseries_maps)

 Parameter definitions

ParameterTypeDescription
constant_valueNumber. Default is NoneThe numeric value to use when generating a single MTS
key_mapsPython map or list of maps. Default is NoneThe dimensions and values to insert into the MTS
timeseries_mapsList of maps. Default is ``If specified, generates multiple constant MTS in the output stream. Each map in the list contains a
key map and a value constant.

 Examples

 Using const() to create a single timeseries

This SignalFlow expression publishes a single timeseries without any dimensions:

const(value=.5).publish()

To add dimensions to it, add the key parameter:

const(value=.5, key={"host": "host2"}).publish()

 Using const() to create multiple timeseries

Test distinct static thresholds for a set of dimension values by generating multiple MTS using const(). Specify each MTS in the timeseries parameter. Don’t specify value and key as arguments to const(); instead, specify them in the value of timeseries.

#Define thresholds with two MTS:
#1. 'aws_region:us-east-1' dimension with a value of 75
#2. 'aws_region:us-west-1' dimension with a value of 85
thresholds = const(timeseries=[
    {'key': {'aws_region': 'us-east-1'}, 'value': 75},
    {'key': {'aws_region': 'us-west-1'}, 'value': 85}])

#Use those thresholds in a detector and let correlation do the work
detect(data('cpu.utilization').promote('aws_region') > thresholds).publish('cpu too high')