addStatelessMetrics
Syntax
addStatelessMetrics(engine, metrics)
Details
Adds computation metrics to a reactive stateless engine.
Parameters
engine is a STRING scalar or an object, specifying the reactive stateless engine to which computation metrics are added.
metrics is a table that specifies computation metrics to be added.
- formula: A STRING value that specifies the computation logic. Variables are identified by the values in the column specified by keyColumn. If keyColumn specifies multiple columns, the values are joined with
:. - outputMetricKey: A STRING value that specifies the metric name for this computation.
- triggerOn: A STRING value that specifies the data identifier triggering this computation. The computation is triggered when the column specified by keyColumn has this value. If keyColumn specifies multiple columns, the values are joined with
:. - filter: A data pair that specifies the scope of the computation results. Only results within this scope are output.
Examples
Create a reactive stateless engine that calculates factor1 + factor2, then add a rule that calculates factor1 * factor2.
// Create the input and output tables and the initial rule
inputTable = table(1:0, `metricKey`timestamp`value, [STRING, TIMESTAMP, DOUBLE])
outputTable = table(1:0, `metricKey`timestamp`value, [STRING, TIMESTAMP, DOUBLE])
initialMetrics = table(
['"factor1" + "factor2"'] as formula,
["value1"] as outputMetricKey,
["factor1"] as triggerOn,
[0:100] as filter
)
statelessEngine = createReactiveStatelessEngine(
name="factorMetricEngine", metrics=initialMetrics, outputTable=outputTable,
dummyTable=inputTable, keyColumn="metricKey", timeColumn="timestamp"
)
// Add a rule triggered by factor1 updates, with results filtered to [10, 20]
metricsTable = table(
['"factor1" * "factor2"'] as formula,
["value3"] as outputMetricKey,
["factor1"] as triggerOn,
[10:20] as filter
)
addStatelessMetrics(statelessEngine, metrics=metricsTable)
// Write input data: factor2 is 3 and factor1 is 4
data = table(
["factor2", "factor1"] as metricKey,
[2026.02.01T09:00:00.000, 2026.02.01T09:00:00.001] as timestamp,
[3.0, 4.0] as value
)
statelessEngine.append!(newData=data)
result = select * from outputTable order by metricKey
// Remove the engine created in this example and view the results
dropStreamEngine(name="factorMetricEngine")
result
| metricKey | timestamp | value |
|---|---|---|
| value1 | 2026.02.01T09:00:00.001 | 7 |
| value3 | 2026.02.01T09:00:00.001 | 12 |
Related functions: getStatelessMetrics, deleteStatelessMetrics
