-
Notifications
You must be signed in to change notification settings - Fork 491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
body
inline template, oruseBody
flag. Instead, you can supplybodyTemplate
to 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
getTemplate
andpostTemplate
to select a template to use for building urls. They havebodyTemplate
to select a template to use for post or email body (default isbody
) andemailSubjectTemplate
to select a template to use for the email subject.