Extend discord messages with content (#4007)
* Extend discord messages with content Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com> Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com> * Updated configuration.md Updated assets_vfsdata.go Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com> * Fix grammar Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com> * Updated vfsdata Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com> --------- Signed-off-by: Yevhen Sydorenko <mogoll92@gmail.com>
This commit is contained in:
parent
69fe3f81fa
commit
6b77acd166
|
@ -163,9 +163,9 @@ var Assets = func() http.FileSystem {
|
|||
"/templates/default.tmpl": &vfsgen۰CompressedFileInfo{
|
||||
name: "default.tmpl",
|
||||
modTime: time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC),
|
||||
uncompressedSize: 8053,
|
||||
uncompressedSize: 8101,
|
||||
|
||||
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\x59\xcf\x6f\xeb\x36\x0c\xbe\xe7\xaf\x20\xfc\x76\x68\x0e\xf5\x1b\x76\x2c\x50\x0c\x0f\xc3\x7e\x1c\xba\x61\x68\xd1\x5d\x86\x21\x50\x6d\xc6\x55\x2b\x4b\xae\x44\x27\x0d\xd2\xfc\xef\x83\x6c\xc7\x91\x6c\x27\x91\xd3\xec\xb4\xdc\x12\x99\xfc\x48\x7f\x1f\x4d\x4a\xf6\x7a\x0d\x29\xce\xb9\x44\x88\x66\x33\x26\x50\x53\xce\x24\xcb\x50\x47\xb0\xd9\x7c\x73\xfe\xaf\xd7\x80\x32\x85\xcd\x66\xb2\xd7\xe5\xf1\xfe\xce\x7a\xad\xd7\x10\xff\xfc\x4e\xa8\x25\x13\x8f\xf7\x77\xb0\xd9\x7c\xfd\xf2\xb5\xb2\x33\x3f\x6a\x4c\x90\x2f\x50\xdf\x5a\xa3\xfb\xe6\x0f\x7c\x40\xa9\xc5\x5b\x89\x7a\x55\xbb\x37\x81\xfc\x48\xa6\x7c\x7a\xc1\x84\x6c\x84\xbf\xad\xf7\x03\x31\x2a\x0d\x7c\x00\xa9\xc7\xa2\x40\x5d\xbb\xf2\x39\xe0\x5b\x7b\x31\x9a\x73\xcd\x65\x66\x7d\x6e\xac\x4f\x75\x43\x26\xfe\xa5\x5a\x85\x0f\x10\x28\xdd\x88\xff\x80\x35\xfa\x55\xab\xb2\xb8\x63\x4f\x28\x4c\xfc\xa0\x34\x61\xfa\x27\xe3\xda\xc4\x7f\x31\x51\xa2\x0d\xf8\xa2\xb8\x84\x08\x2c\x2a\xd4\x21\x33\x82\x2b\x8b\x15\xff\xa4\xf2\x5c\xc9\xda\x79\xda\xac\x39\x78\x53\xd8\x6c\xae\xd6\x6b\x58\x72\x7a\xf6\x8d\xe3\x7b\xcc\xd5\x02\xfd\xe8\x7f\xb0\x1c\x4d\xc3\xe8\x50\xf4\x36\xf1\x69\xfb\x6b\x8f\x4c\x29\x9a\x44\xf3\x82\xb8\x92\xd1\x01\x8e\x09\xdf\xa9\x96\x74\x26\xb8\xa1\xc6\x54\x33\x99\x21\xc4\xb0\xd9\xd4\x79\xdd\x4c\x76\x8b\x7d\x9e\x2c\x2b\xd7\x15\x91\x36\x7d\xfb\xef\x16\xda\x1b\x68\x12\xab\x83\x7f\x93\x52\x11\xb3\x39\x79\x90\xce\xf2\x69\xb8\x0f\xaa\xd4\x09\xde\xd4\x62\xa2\x44\xcd\x48\xe9\xba\x12\x27\x03\x44\x1d\xa4\x60\x96\x33\xfd\x9a\xaa\xa5\xec\x71\x31\x09\x25\x23\x30\xeb\xc9\x78\x3a\x42\x91\x83\x08\x99\x0c\x33\x62\x04\x4b\x5e\xe3\x14\xe7\xac\x14\x14\x13\x27\x81\x0d\x15\x84\x79\x21\x18\xf9\x0f\x67\xbc\xaf\x06\x7d\x9c\xd2\xd8\xf6\x90\x0f\x41\xf9\x4d\x28\x10\x6f\xce\x84\x78\x62\xc9\x6b\x0f\x6f\x30\x7d\x0b\x0a\x1f\x70\xcc\x50\x70\xf9\x1a\x9c\x41\xd2\x64\xc0\xd3\x28\xcc\xa1\xd0\x68\x6b\x2d\xd0\xda\x49\xe8\x20\x63\x55\x0f\x0e\x4c\x99\x27\x4a\x62\xae\x5e\x78\x14\x6e\x5f\x6a\x11\x9a\x71\xf8\xcd\xcd\x95\xa2\x7a\xe2\x38\x35\xe8\x9a\x17\xf6\xd6\xd2\x92\x56\xad\x4b\xbf\xa1\x8d\x2b\xc7\x3e\x62\x22\x38\x4a\x3a\xbd\x20\xf7\x21\xee\xa6\xe2\x69\x9a\xf5\x71\xb9\x34\xc4\x64\x82\x66\x00\xb7\xd7\xc1\xe3\xfd\xac\xaa\xc2\x64\x28\x39\xb6\xc0\x39\x1a\xc3\xb2\xd3\x9e\xef\x1e\x58\x5f\xa1\x66\xe0\xed\x69\x68\x83\x13\x6e\xd2\x99\xaf\xde\x00\x9f\xc2\xf7\x70\x6d\x1b\x67\xb5\x08\xf5\x62\xd5\x3a\x0f\x33\xe2\xef\x02\xaa\x20\xd7\xce\x1d\x0d\xc4\xbb\x47\xa3\xc4\x02\xd3\x4e\xc4\xed\x72\x78\xcc\xad\x47\x2f\xea\x75\x08\xa5\xa6\xea\xe3\xe3\xab\xc9\x53\x7d\x89\xc9\x33\xa3\xb1\x9a\x4f\x2e\xfa\x1d\xd0\xcf\xdd\x28\x3f\x6a\xd1\xc3\x1b\xd4\x67\x8f\xea\x1d\x7d\x48\xcd\xec\xb0\xdc\xdb\x49\xfb\xe6\x05\xd3\xb4\x1a\x61\x4f\x2c\x0b\xb5\x66\x19\x4a\x9a\x75\x47\x9c\x5f\x5f\x0b\x9e\x90\xd2\xaa\x30\xbb\xb2\x25\x46\x38\xf3\x0b\xed\x52\x4b\xe3\x7a\x41\x9f\x55\x94\xc4\x69\x35\x4b\xb9\x29\x04\x5b\xcd\xf6\xec\xa6\x8e\x37\xee\x3e\x72\xae\x24\x27\x65\x09\x99\x91\x52\x62\xe4\x48\xf4\x66\x57\x69\x9e\xd5\x02\xf5\x19\xf6\x8f\x3d\xa8\xff\xbe\x9e\xce\x53\x4e\xe1\xd5\x74\xbe\x62\xea\x6f\xe9\x0f\x31\xb9\xdb\xd3\x8d\x99\x29\xee\x6e\x4e\x3a\x0f\xfb\xee\x98\x3e\xfe\x8c\xe0\xe0\x5c\xe4\x1d\x23\xaf\xcb\x22\xa1\xc0\x4c\xb3\x7c\x88\xca\xff\x2d\x29\x29\x37\x89\xd2\xe9\x19\x1a\x51\x17\xe9\xc2\xae\xdd\x26\x3c\xe1\xfb\xe5\xd1\xfd\x34\x8f\xb9\x21\x64\xb9\xdb\x4c\xf3\x9c\xe9\xd5\x49\x75\xda\xc5\x3a\xbd\xe2\x7b\x48\xcd\xc9\x3e\x44\xa6\x2f\x30\x4a\x28\xe7\x75\xdb\xa7\x15\x6b\x43\x87\x6a\x36\x10\xfc\x04\xf1\x16\x3f\x9c\x8f\x72\x17\xeb\x42\xfa\x10\xe9\x2f\x5c\xb3\xb3\x3c\x2e\x1e\x50\xe7\xdd\xc5\x85\xf3\x49\x75\x2c\x19\xe4\xaa\xd0\x5c\x69\x6e\x4f\x9c\xd7\xcd\xe9\xe5\xbb\xed\x12\xdc\xdc\x42\x14\x6d\x0f\x35\xdb\xf7\xd9\xde\xdd\x5a\x1f\x00\x80\xca\xcf\xe0\x02\xb7\x7e\x5c\xa6\xf8\xbe\x7d\xa5\x0e\xd1\xf6\x52\xe4\x79\xf0\x39\x5c\xe1\x9b\xe3\x18\x25\x9a\x13\x4f\x98\x88\xa6\xad\x61\x0b\xdf\xa6\x75\x0b\xd1\x6f\x3c\x7b\xf6\xb1\x50\x18\xac\x00\x99\x4c\xbb\xa8\x4b\xa6\x25\x97\x59\x34\x85\x2b\x89\x0e\x50\x0d\x33\x3d\x12\xeb\x77\x4c\x79\x99\x87\x47\xe3\x72\xae\x6c\x28\xbb\xba\x0b\x75\x34\xcc\x9d\x5a\x76\x62\xc8\xb4\xd5\xc4\xfd\x5d\x7f\x23\x73\xa1\x3d\x37\x5f\xa7\xb6\x30\x7a\xb1\x47\xa9\x35\x5a\xb1\x00\xd5\xce\xae\x5c\x90\x7a\xe7\x53\xf0\xb8\x8a\x5d\x25\x8f\x29\xbb\x43\xea\x5e\x75\x5b\x9d\x56\xc9\x2b\x92\xff\x1a\xe8\xe4\x49\x35\x00\xc6\x04\x67\xe6\xf4\x17\xe9\xfb\xd2\xfb\xf4\xd7\x8f\x01\xe0\xc3\x9f\x3f\x06\x1c\x8e\x7d\x03\x19\x4a\xbe\xf7\x21\xe4\xdf\x00\x00\x00\xff\xff\xde\xd1\xa3\x9d\x75\x1f\x00\x00"),
|
||||
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\x59\xcf\x6f\xeb\x36\x0c\xbe\xe7\xaf\x20\xfc\x76\x68\x0e\xf5\x1b\x76\x2c\x50\x0c\x0f\xc3\x7e\x1c\xba\x61\x68\xd1\x5d\x86\x21\x50\x6d\xc6\x55\x2b\x4b\xae\x44\x27\x0d\xd2\xfc\xef\x83\x6c\xc7\x91\x2d\x27\x91\xd3\xec\xb4\xdc\x12\x99\xfc\x48\x7f\x1f\x4d\xca\xf2\x7a\x0d\x29\xce\xb9\x44\x88\x66\x33\x26\x50\x53\xce\x24\xcb\x50\x47\xb0\xd9\x7c\x73\xfe\xaf\xd7\x80\x32\x85\xcd\x66\xb2\xd7\xe5\xf1\xfe\xce\x7a\xad\xd7\x10\xff\xfc\x4e\xa8\x25\x13\x8f\xf7\x77\xb0\xd9\x7c\xfd\xf2\xb5\xb2\x33\x3f\x6a\x4c\x90\x2f\x50\xdf\x5a\xa3\xfb\xe6\x0f\x7c\x40\xa9\xc5\x5b\x89\x7a\x55\xbb\x37\x81\xba\x91\x4c\xf9\xf4\x82\x09\xd9\x08\x7f\x5b\xef\x07\x62\x54\x1a\xf8\x00\x52\x8f\x45\x81\xba\x76\xe5\x73\xc0\xb7\xf6\x62\x34\xe7\x9a\xcb\xcc\xfa\xdc\x58\x9f\xea\x86\x4c\xfc\x4b\xb5\x0a\x1f\x20\x50\xba\x11\xff\x01\x6b\xf4\xab\x56\x65\x71\xc7\x9e\x50\x98\xf8\x41\x69\xc2\xf4\x4f\xc6\xb5\x89\xff\x62\xa2\x44\x1b\xf0\x45\x71\x09\x11\x58\x54\xa8\x43\x66\x04\x57\x16\x2b\xfe\x49\xe5\xb9\x92\xb5\xf3\xb4\x59\x73\xf0\xa6\xb0\xd9\x5c\xad\xd7\xb0\xe4\xf4\xdc\x35\x8e\xef\x31\x57\x0b\xec\x46\xff\x83\xe5\x68\x1a\x46\x87\xa2\xb7\x89\x4f\xdb\x5f\x7b\x64\x4a\xd1\x24\x9a\x17\xc4\x95\x8c\x0e\x70\x4c\xf8\x4e\xb5\xa4\x33\xc1\x0d\x35\xa6\x9a\xc9\x0c\x21\x86\xcd\xa6\xce\xeb\x66\xb2\x5b\xf4\x79\xb2\xac\x5c\x57\x44\xda\xf4\xed\xbf\x5b\x68\x6f\xa0\x49\xac\x0e\xfe\x4d\x4a\x45\xcc\xe6\xd4\x81\x74\x96\x4f\xc3\x7d\x50\xa5\x4e\xf0\xa6\x16\x13\x25\x6a\x46\x4a\xd7\x95\x38\x19\x20\xea\x20\x05\xb3\x9c\xe9\xd7\x54\x2d\xa5\xc7\xc5\x24\x94\x8c\xc0\xac\x27\xe3\xe9\x08\x45\x0e\x22\x64\x32\xcc\x88\x11\x2c\x79\x8d\x53\x9c\xb3\x52\x50\x4c\x9c\x04\x36\x54\x10\xe6\x85\x60\xd4\x7d\x38\xe3\x7d\x35\xd8\xc5\x29\x8d\x6d\x0f\xf9\x10\x54\xb7\x09\x05\xe2\xcd\x99\x10\x4f\x2c\x79\xf5\xf0\x06\xd3\xb7\xa0\xf0\x01\xc7\x0c\x05\x97\xaf\xc1\x19\x24\x4d\x06\x3c\x8d\xc2\x1c\x0a\x8d\xb6\xd6\x02\xad\x9d\x84\x0e\x32\x56\xf5\xe0\xc0\x94\x79\xa2\x24\xe6\xea\x85\x47\xe1\xf6\xa5\x16\xa1\x19\x87\xdf\xdc\x5c\x29\xaa\x27\x8e\x53\x83\xae\x79\x61\x6f\x2d\x2d\x69\xd5\xba\xf8\x0d\x6d\x5c\x39\xfa\x88\x89\xe0\x28\xe9\xf4\x82\xdc\x87\xb8\x9b\x8a\xa7\x69\xe6\xe3\x72\x69\x88\xc9\x04\xcd\x00\xae\xd7\xc1\xe3\xfd\xac\xaa\xc2\x64\x28\x39\xb6\xc0\x39\x1a\xc3\xb2\xd3\x9e\x6f\x0f\xcc\x57\xa8\x19\x78\x7b\x1a\xda\xe0\x84\x9b\xf4\xe6\x6b\x67\x80\x4f\xe1\x7b\xb8\xb6\x8d\xb3\x5a\x84\x7a\xb1\x6a\x9d\x87\x19\xe9\xee\x02\xaa\x20\xd7\xce\x1d\x0d\xc4\xbb\x47\xa3\xc4\x02\xd3\x5e\xc4\xed\x72\x78\xcc\xad\x87\x17\xf5\x3a\x84\x52\x53\xf5\xf1\xf1\xd5\xd4\x51\x7d\x89\xc9\x33\xa3\xb1\x9a\x4f\x2e\xfa\x1d\xd0\xcf\xdd\x28\x3f\x6a\xe1\xe1\x0d\xea\xb3\x47\xf5\x9e\x3e\xa4\x66\x76\x58\xee\xed\xa4\xbe\x79\xc1\x34\xad\x46\xd8\x13\xcb\x42\xad\x59\x86\x92\x66\xfd\x11\xd7\xad\xaf\x05\x4f\x48\x69\x55\x98\x5d\xd9\x12\x23\x9c\x75\x0b\xed\x52\x4b\xe3\x7a\x81\xcf\x2a\x4a\xe2\xb4\x9a\xa5\xdc\x14\x82\xad\x66\x7b\x76\x53\xc7\x1b\xb7\x8f\x9c\x2b\xc9\x49\x59\x42\x66\xa4\x94\x18\x39\x12\x3b\xb3\xab\x34\xcf\x6a\x81\xfa\x0c\xfb\x47\x0f\xea\xbf\xaf\xa7\xf3\x94\x53\x78\x35\x9d\xaf\x98\xfc\x2d\xfd\x21\x26\x77\x7b\xba\x31\x33\xc5\xdd\xcd\x49\xe7\x61\xdf\xbd\xa6\x8f\x7f\x47\x70\x70\x2e\xf2\x8e\x91\xd7\x65\x91\x50\x60\xa6\x59\x3e\x44\xe5\xff\x96\x94\x94\x9b\x44\xe9\x74\xb7\x37\x57\x92\x76\xdb\x7d\xbf\x14\xfb\xf6\xa7\x37\xae\x3e\xd2\x45\x0d\xbb\xad\x78\xc2\xf7\xcb\xa3\xfe\x69\x1e\x73\x43\xc8\x72\xb7\xf9\xe6\x39\xd3\xab\x93\xea\xb4\x8f\x75\x7a\xc5\x7b\x48\xcd\x49\x40\x88\x4c\x5f\x60\x94\x50\xce\xf1\xdc\xa7\x15\x6b\x43\x87\x6a\x36\x10\xfc\x04\xf1\x16\x3f\x9c\x8f\x72\x17\xeb\x42\xfa\x10\xe9\x2f\x5c\xb3\xb3\x3c\x2e\x1d\xa0\xde\x59\xc7\x85\xf3\x49\xf5\x1a\x33\xc8\x55\xa1\xb9\xd2\xdc\xbe\xa1\x5e\x37\x6f\x3b\xdf\x6d\x97\xe0\xe6\x16\xa2\x68\xfb\x12\xb4\x3d\xff\xee\xdc\xad\xf5\x01\x00\xa8\xfc\x0c\x2e\x70\xeb\xc7\x65\x8a\xef\xdb\x23\x78\x88\xb6\x97\xa2\x8e\x07\x9f\xc3\x15\xbe\x39\x8e\x51\xa2\x39\xf1\x84\x89\x68\xda\x1a\xb6\xf0\x6d\x5a\xb7\x10\xfd\xc6\xb3\xe7\x2e\x16\x0a\x83\x15\x20\x93\x69\x1f\x75\xc9\xb4\xe4\x32\x8b\xa6\x70\x25\xd1\x01\xaa\x61\xa6\x47\x62\xfd\x8e\x29\x2f\xf3\xf0\x68\x5c\xce\x95\x0d\x65\x57\x77\xa1\x8e\x86\xb9\x53\xcb\x5e\x0c\x99\xb6\x9a\xb8\xbf\xeb\x6f\x6a\x2e\x74\xc7\xad\xab\x53\x5b\x18\x5e\xec\x51\x6a\x8d\x56\x2c\x40\xb5\xb3\x2b\x17\xa4\xde\xf9\x14\x3c\xae\x62\x5f\xc9\x63\xca\xee\x90\xfa\x57\xdd\x56\xa7\x55\xf2\x8a\xd4\x3d\x36\x3a\x79\x52\x0d\x80\x31\xc1\x99\x39\xfd\xe0\x7d\x5f\x7a\x9f\xfe\x5a\x32\x00\x7c\xf8\x73\xc9\x80\xc3\xb1\x6f\x26\x43\xc9\x7b\x1f\x4e\xfe\x0d\x00\x00\xff\xff\x74\x5d\xc4\xb5\xa5\x1f\x00\x00"),
|
||||
},
|
||||
"/templates/email.tmpl": &vfsgen۰CompressedFileInfo{
|
||||
name: "email.tmpl",
|
||||
|
|
|
@ -251,6 +251,7 @@ type DiscordConfig struct {
|
|||
WebhookURL *SecretURL `yaml:"webhook_url,omitempty" json:"webhook_url,omitempty"`
|
||||
WebhookURLFile string `yaml:"webhook_url_file,omitempty" json:"webhook_url_file,omitempty"`
|
||||
|
||||
Content string `yaml:"content,omitempty" json:"content,omitempty"`
|
||||
Title string `yaml:"title,omitempty" json:"title,omitempty"`
|
||||
Message string `yaml:"message,omitempty" json:"message,omitempty"`
|
||||
}
|
||||
|
|
|
@ -883,6 +883,9 @@ webhook_url_file: <filepath>
|
|||
# Message body template.
|
||||
[ message: <tmpl_string> | default = '{{ template "discord.default.message" . }}' ]
|
||||
|
||||
# Message content template. Limited to 2000 characters.
|
||||
[ content: <tmpl_string> | default = '{{ template "discord.default.content" . }}' ]
|
||||
|
||||
# The HTTP client's configuration.
|
||||
[ http_config: <http_config> | default = global.http_config ]
|
||||
```
|
||||
|
|
|
@ -38,6 +38,8 @@ const (
|
|||
maxTitleLenRunes = 256
|
||||
// https://discord.com/developers/docs/resources/channel#embed-object-embed-limits - 4096 characters or runes.
|
||||
maxDescriptionLenRunes = 4096
|
||||
|
||||
maxContentLenRunes = 2000
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -115,6 +117,14 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
|
|||
level.Warn(n.logger).Log("msg", "Truncated message", "key", key, "max_runes", maxDescriptionLenRunes)
|
||||
}
|
||||
|
||||
content, truncated := notify.TruncateInRunes(tmpl(n.conf.Content), maxContentLenRunes)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "Truncated message", "key", key, "max_runes", maxContentLenRunes)
|
||||
}
|
||||
|
||||
color := colorGrey
|
||||
if alerts.Status() == model.AlertFiring {
|
||||
color = colorRed
|
||||
|
@ -135,6 +145,7 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
|
|||
}
|
||||
|
||||
w := webhook{
|
||||
Content: content,
|
||||
Embeds: []webhookEmbed{{
|
||||
Title: title,
|
||||
Description: description,
|
||||
|
|
|
@ -123,6 +123,7 @@ Alerts Resolved:
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ define "discord.default.content" }}{{ end }}
|
||||
{{ define "discord.default.title" }}{{ template "__subject" . }}{{ end }}
|
||||
{{ define "discord.default.message" }}
|
||||
{{ if gt (len .Alerts.Firing) 0 }}
|
||||
|
|
Loading…
Reference in New Issue