-
Notifications
You must be signed in to change notification settings - Fork 491
cmd/bosun: major notification overhaul #2135
Conversation
cmd/bosun/conf/rule/rule.go
Outdated
| n.UseBody = v == "true" | ||
| default: | ||
| c.errorf("unknown key %s", k) | ||
| m := map[interface{}]interface{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is meant to build JSON, should be a map[string]interface or it won't marshal into JSON
cmd/bosun/conf/rule/rule.go
Outdated
| "makeSlice": func(vals ...interface{}) interface{} { | ||
| return vals | ||
| }, | ||
| "makeMap": func(vals ...interface{}) (interface{}, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to think, but avoid return errors here because we don't wan't to completely break the template. See the docs at http://bosun.org/definitions#template-error-handling
Somewhat related, we might need an "error" template type for fallback with templates error... same case with JSON.
|
When I set the content type with the following: I see the content type displayed in the the UI, but when I test the notification I don't see the Content-Type header set with using |
|
Oops, wasn't setting headers. fixed. |
Presumably as part of the PR bosun-monitor#2135 three new global template functions were added: json, makeSlice, and makeMap. However they are not mentioned nor documented at http://bosun.org/definitions. This commit attempts to fill in the gap.
Presumably as part of the PR #2135 three new global template functions were added: json, makeSlice, and makeMap. However they are not mentioned nor documented at http://bosun.org/definitions. This commit attempts to fill in the gap.
…-monitor#2241) Presumably as part of the PR bosun-monitor#2135 three new global template functions were added: json, makeSlice, and makeMap. However they are not mentioned nor documented at http://bosun.org/definitions. This commit attempts to fill in the gap.

Makes notifications more individually configurable.
BREAKING CHANGES:
Notifications no longer support
bodyinline template, oruseBodyflag. Instead, you can supplybodyTemplateto select any pre-rendered template key on the alert's template:Old:
New:
Templates can now include arbitrarily named keys (not just subject and body anymore), and they will all be pre-rendered when the alert fires, with the full context of the alert.
Features
Can add arbitrary keys to templates, as explained above.
Templates can "inherit" another template, essentially copying all of their keys/values that are not already defined:
Notifications now support
getTemplateandpostTemplateto select a template to use for building urls. They havebodyTemplateto select a template to use for post or email body (default isbody) andemailSubjectTemplateto select a template to use for the email subject.