When built-in templates cannot express multi-signal conditions or duration rules, write Custom SignalFlow detectors with detect() and when().
The when(predicate, lasting=..., at_least=...) function turns a boolean condition (such as cpu > 90) into an event trigger. Adding lasting='5m' requires the condition to remain true across a 5-minute window before firing, while at_least=0.8 allows triggering if it holds for 80% of that window (tolerance for brief 1-sample dips).
Passing the when() expression into detect() creates the alert stream, and calling .publish('Alert Rule Name') registers it as an active rule inside the detector.
cpu = data('cpu.utilization').mean(by='host.name')
detect(when(cpu > 90, lasting='5m', at_least=1.0)).publish('Sustained High CPU')