Standardize event metadata and notification template #1529
Unanswered
phillebaba
asked this question in
Proposals
Replies: 2 comments 3 replies
-
I propose we introduce a new API type called |
Beta Was this translation helpful? Give feedback.
3 replies
-
suggest support customizing Generic webhook provider's playload(post body data). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
There have been some discussions notification-controller issues regarding extending configuration of the notifications being sent. Some of the are related to commit status notifications and other two chat notifications. What they have in common is that they could all be solved with allowing end users to create their own templates for the notifications.
fluxcd/notification-controller#194
fluxcd/notification-controller#195
Image automation already has a similar feature implemented so we should try to make this solution as similar to the existing one as possible.
https://fluxcd.io/docs/guides/image-update/#configure-the-commit-message
Proposal
Looking around there is already a project that solves this type of problem. Alertmanager allows notification templating for individual alerts using go templating, and I don't see a reason why we should re invent the wheel. Another solution which would extend its functionality would be to use Sprig which would add functionality that Helm has.
https://prometheus.io/docs/alerting/latest/notification_examples/
http://masterminds.github.io/sprig/
If we are going to expose templates to the end user we need to decide and document the parameters from the Event which should be available for the end user. It will be difficult to change names or remove parameters once the initial version is released so this should also be the time to make any changes to the event metadata.
Given that there is already a feature request to implement Sprig in Image Automation I expect that people would request it in the Notification Controller if it is not initially included.
fluxcd/image-automation-controller/issues/160
Metadatata
Currently chat notifications will for the most part use the events InvolvedObjects Kind, Name, and Namespace as the authors name. Then it will take the whole message from the event and use it as the message.
The git status notifications are a bit different as they do not use the message at all. This is mostly because there are character limits imposed by the Git providers. Git providers have two fields a key (also called genre, or context) and then a description. This could in theory be considered the same as an author and message. Currently the key is created from the InvolvedObject Kind and Name while the description is created from the event Reason. On top of this the commit status notification relies on the
revision
metadata in the event which is only set by the Kustomize Controller right now.Given these two use cases which should at minimum expose the following parameters from the event to be used in the template.
Configuration
The chat and commit status notification may look different but I think there are enough similarities to allow for a common set of configuration which could be used in both. My suggestion is to add two new parameters to the alert object. An author template and a message template. For chat notifications these are self explanatory and for commit status notifications the author is used for the key and message is used for the description.
The yaml could look something like this.
Of course the default behavior should be used if the template is not specified to keep backwards compatibility.
Extra Features
Beta Was this translation helpful? Give feedback.
All reactions