Right now an AlertNode will send an alert of any level to all configured handlers.
To send them to different endpoints you can create multiple alert node that only send alerts for certain levels.
Maybe we should change it so that each level is a node and can have its own handlers.
Example: Send INFO alerts to email, send WARNING and CRITICIAL alerts to http endpoint and log them.
Currently this can be done this way:
var data = stream. ....
data
.alert()
.info(...)
.email(...)
data
.alert()
.warn(...)
.crit(...)
.post(...)
.log(...)
Would something like this make more sense?
var alertNode = stream ....
.alert()
alertNode
.info(...)
.email(...)
alertNode
.warn(...)
.post(...)
.log(...)
alertNode
.crit(...)
.post(...)
.log(...)
The second method will be inefficient as it has to evaluate all three alert conditions where as the first method can break out early if its only a warning.
I like the way it is now so maybe just some good examples is all we need.
@pauldix Thoughts?
No one has asked for this closing.
The docs could use an example calling out how to achieve do this. I wanted to do configure alerts this way and didn't figure out how until finding this issue and seeing that first example.
@nathanielc I think it's a very nice feature, for example on critical alerts I would like to send an email alerts on some specific alerts - but it's must be combined with noStateChanges.
But I can't understand what is the difference between the methods, the first methods seems pretty good:
var data = ...
// Send info and warn to alert service
data.alert().info().warn().post('my-alert-service')
// Send crit to alert service and *email*
data.alert().crit().email().post('my-alert-service')
@yosiat Yes, the first method is the one that works. The second method was a proposed different way of doing it that is no longer valid. Since the first method works we should document it in the AlertNode examples so its easier to find.
Most helpful comment
@yosiat Yes, the first method is the one that works. The second method was a proposed different way of doing it that is no longer valid. Since the first method works we should document it in the AlertNode examples so its easier to find.