prometheus-msteams: Alert object should not be pre-json or pre-markdown escaped in card json-templating by default
Is your feature request related to a problem? Please describe.
Introduced in v1.2.0
, in particular https://github.com/prometheus-msteams/prometheus-msteams/pull/82, the alert object is pre-json and pre-markdown escaped for convenience, so that json-templating the card is simpler.
Describe the solution you’d like The convenience of pre-json and pre-markdown escaping is great for new users, or users unfamililar to templating json, because templating the card is simpler. However, the raw strings in the prometheus alert object is lost (or is considered polluted), and any escaping performed in the template now double escapes the Alert object’s strings.
Describe alternatives you’ve considered
Do not pre-json-escape or pre-markdown-escape by default. Since v1.3.0 with the new custom connector in config.yml
there is an option to disable markdown-escaping the Alert object; however there is no such option for json-escaping the Alert object.
Moreover, I believe some users of prometheus-msteams
should have enough familiarity with markdown and json that they prefer to be handling templating with full control over how the final json will be generated. A proper templating library such as sprig
as discussed in a previous issue will make newcomers as well as those familiar with making helm charts have an easier time with templating json.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (5 by maintainers)
Got it. I agree working with yaml format would be way simpler. I was concerned a little bit first as examples in the MS Teams documentation are provided in JSON format, so I thought JSON is a better way to directly reference it. But templating all stuff is a whole different point. I think it is a good idea and will make look the templates a lot cleaner.
Let’s try to implement it in either #116 or in a new PR afterwards.
yes, I was referring to the same flag.
jsonEscapeMessage
function is called, which callsjsonEncodeAlertmanagerKV
which is in reality, is json-encoding followed by markdown-escaping, instead of having distinct flags for each step.https://github.com/prometheus-msteams/prometheus-msteams/blob/253fb5913ec955bf591fac7944a722c2b84e44fb/pkg/card/templated_card.go#L294-L298