diff --git a/asset/assets_vfsdata.go b/asset/assets_vfsdata.go index 16ab608eb3..a4fd6e766b 100644 --- a/asset/assets_vfsdata.go +++ b/asset/assets_vfsdata.go @@ -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: 7283, + uncompressedSize: 7440, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\x59\xcd\x6e\xeb\x36\x13\xdd\xfb\x29\x06\xba\xdf\x22\x5e\x44\xf7\x5b\x07\x08\x8a\x8b\xa2\x3f\x8b\xb4\x28\x1c\xa4\x9b\xa2\x10\x18\x69\xac\x30\xa1\x48\x85\x1c\xd9\x31\x1c\xbd\x7b\x41\x49\x96\x45\x49\xb6\x29\x5f\x77\x55\xef\x62\x7a\xe6\x9c\xe1\x39\xa3\x21\xe5\x6c\xb7\x90\xe0\x92\x4b\x84\x20\x8a\x98\x40\x4d\x19\x93\x2c\x45\x1d\x40\x59\x7e\xeb\x7c\xde\x6e\x01\x65\x02\x65\x39\x3b\x98\xf2\xb4\x78\xb0\x59\xdb\x2d\x84\x3f\x7d\x10\x6a\xc9\xc4\xd3\xe2\x01\xca\xf2\xeb\x97\xaf\x55\x9c\xf9\x41\x63\x8c\x7c\x85\xfa\xde\x06\x2d\x9a\x0f\xf0\x09\x85\x16\xef\x05\xea\x4d\x9d\xde\x10\xb9\x4c\xa6\x78\x7e\xc5\x98\x2c\xc3\x5f\x36\xfb\x91\x18\x15\x06\x3e\x81\xd4\x53\x9e\xa3\xae\x53\xf9\x12\xf0\xbd\xfd\x32\x58\x72\xcd\x65\x6a\x73\xee\x6c\x4e\xb5\x21\x13\xfe\x5c\xad\xc2\x27\x08\x94\x5d\xc6\xbf\xc1\x06\xfd\xa2\x55\x91\x3f\xb0\x67\x14\x26\x7c\x54\x9a\x30\xf9\x83\x71\x6d\xc2\x3f\x99\x28\xd0\x12\xbe\x2a\x2e\x21\x00\x8b\x0a\x35\x65\x4a\x70\x63\xb1\xc2\x1f\x55\x96\x29\x59\x27\xcf\x9b\xb5\x0e\xde\x1c\xca\xf2\x66\xbb\x85\x35\xa7\x17\x37\x38\x5c\x60\xa6\x56\xe8\xb2\xff\xce\x32\x34\x8d\xa2\x63\xec\x6d\xe1\xf3\xf6\xaf\x03\x36\x25\x68\x62\xcd\x73\xe2\x4a\x06\x47\x34\x26\xfc\xa0\xda\xd2\x48\x70\x43\x4d\xa8\x66\x32\x45\x08\xa1\x2c\xeb\xba\xee\x66\xfb\xc5\xa1\x4e\x56\x95\xdb\x4a\x48\x5b\xbe\xfd\x74\x0f\xed\x06\x9a\xc2\x6a\xf2\x6f\x52\x2a\x62\xb6\x26\x07\xb2\xb3\x7c\x1e\xee\xa3\x2a\x74\x8c\x77\xb5\x99\x28\x51\x33\x52\xba\xee\xc4\xd9\x88\x50\x47\x25\x88\x32\xa6\xdf\x12\xb5\x96\x03\x2d\x66\xbe\x62\x78\x56\x3d\x9b\x2e\x87\x2f\xb2\x97\x20\xb3\x71\x45\x8c\x60\xf1\x5b\x98\xe0\x92\x15\x82\x42\xe2\x24\xb0\x91\x82\x30\xcb\x05\x23\xf7\xe1\x0c\x0f\xf5\xa0\x8b\x53\x18\x3b\x1e\xb2\x31\x28\x77\x08\x79\xe2\x2d\x99\x10\xcf\x2c\x7e\x1b\xe0\x8d\x96\x6f\x41\xe1\x13\x4e\x05\x0a\x2e\xdf\xbc\x2b\x88\x9b\x0a\x78\x12\xf8\x25\xe4\x1a\x6d\xaf\x79\x46\x77\x0a\x3a\xaa\x58\x35\x83\x3d\x4b\xe6\xb1\x92\x98\xa9\x57\x1e\xf8\xc7\x17\x5a\xf8\x56\xec\xbf\xb9\xa5\x52\x54\x9f\x38\x9d\x1e\xec\x86\xe7\x76\x6b\x49\x41\x9b\x36\x65\x38\xd0\xa6\xb5\xe3\x10\x31\x16\x1c\x25\x9d\xdf\x90\x87\x10\xf7\xa7\xe2\x79\x9e\x0d\x71\xb9\x34\xc4\x64\x8c\x66\x04\x77\x30\xc1\xc3\xc3\xaa\xaa\xdc\xa4\x28\x39\xb6\xc0\x19\x1a\xc3\xd2\xf3\x9e\xef\x01\xd8\xd0\xa1\xe6\xc0\x3b\x30\xd0\x46\x4f\xb8\x59\xef\x7c\x75\x0e\xf0\x39\xfc\x1f\x6e\xed\xe0\xac\x16\xa1\x5e\xac\x46\xe7\x71\x45\xdc\x5b\x40\x45\x72\xdb\xd9\xd1\x08\xdf\x02\x8d\x12\x2b\x4c\x7a\x8c\xbb\x65\x7f\xce\x5d\xc6\x80\xf5\xd6\x47\x52\x53\xcd\xf1\xe9\xdd\xe4\xb8\xbe\xc6\xf8\x85\xd1\x54\xcf\x67\x57\xff\x8e\xf8\xd7\xbd\x28\x3f\x69\x31\xc0\x1b\xf5\xe7\x80\xeb\x3d\x7f\x48\x45\xf6\xb0\x3c\x38\x49\x87\xe1\x39\xd3\xb4\x99\x10\x4f\x2c\xf5\x8d\x66\x29\x4a\x8a\xfa\x47\x9c\xdb\x5f\x2b\x1e\x93\xd2\x2a\x37\xfb\xb6\x25\x46\x18\xb9\x8d\x76\xed\xa5\x69\xb3\x60\xa8\x2a\x4a\xe2\xb4\x89\x12\x6e\x72\xc1\x36\xd1\x81\xdb\xd4\xe9\xc1\x3d\x44\xce\x94\xe4\xa4\xac\x20\x11\x29\x25\x26\x1e\x89\xce\xd9\x55\x98\x17\xb5\x42\x7d\x81\xfb\xe3\x00\xea\xdf\xef\xa7\xcb\xb4\x93\x7f\x37\x5d\xae\x99\x86\x57\xfa\x63\x4a\xee\xef\x74\x53\xce\x94\xee\x6d\x4e\x76\x1e\xf6\xfd\x6b\xfa\xf4\x77\x84\x0e\xce\xd5\xde\x29\xf6\x76\x55\x24\x14\x98\x6a\x96\x8d\x49\xf9\x9f\x15\x25\xe1\x26\x56\x3a\xb9\xc0\x20\xea\x23\x5d\xd5\xb5\xd7\x84\x67\xfc\xb8\x3e\xba\xdf\xad\x63\x66\x08\x59\xd6\x1d\xa6\x59\xc6\xf4\xe6\xac\x3e\xed\x63\x9d\xdf\xf1\x03\xa4\xe6\xcd\xde\xc7\xa6\x2f\x30\xc9\xa8\xce\xcf\x6d\xdf\xed\x58\x4b\xed\xeb\xd9\x08\xf9\x14\xf3\x5e\xb9\x66\x17\x71\xce\x01\xea\xbd\x46\x5f\x35\x9f\x55\x37\xe4\x51\xad\x72\xcd\x95\xe6\xf6\xe5\xe7\xb6\xb9\x48\xff\x6f\xb7\x04\x77\xf7\x10\x04\xbb\xfb\xf5\xee\xa7\x55\x67\xb7\x36\x07\x00\xa0\xca\x33\xb8\xc2\x5d\x1e\x97\x09\x7e\xec\x7e\xdd\x85\x60\xf7\x55\xe0\x64\xf0\x25\xdc\xe0\x7b\x27\x31\x88\x35\x27\x1e\x33\x11\xcc\xdb\xc0\x16\xbe\x2d\xeb\x1e\x82\x5f\x79\xfa\xe2\x62\xa1\x30\x58\x01\x32\x99\xf4\x51\xd7\x4c\x4b\x2e\xd3\x60\x0e\x37\x12\x3b\x40\x35\xcc\xfc\x04\xd7\x6f\x98\xf0\x22\xf3\x67\xe3\x72\xa9\x2c\x95\x5d\xdd\x53\x9d\xa4\x79\x50\xeb\x1e\x87\x4c\x5a\x4f\xba\x7f\xd7\xff\xae\xe9\x42\x3b\x69\xae\x4f\x6d\x63\x0c\xb8\x27\xb9\x35\xd9\x31\x0f\xd7\x2e\xee\x9c\x97\x7b\x97\x73\xf0\xb4\x8b\x7d\x27\x4f\x39\xbb\x47\xea\x7f\xfb\x4f\x00\x00\x00\xff\xff\x30\xb3\x3d\xcd\x73\x1c\x00\x00"), + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\x59\x4d\x6f\xe3\x36\x10\xbd\xfb\x57\x0c\xb4\x3d\xc4\x87\x68\xf7\x1c\x20\x28\x16\x45\x3f\x0e\x69\x51\x64\x91\x5e\x8a\x42\x60\xa4\xb1\xc2\x84\x22\x15\x72\xe4\xc4\x70\xf4\xdf\x0b\x4a\xb2\x2c\xea\xc3\xa6\xbc\xee\xa9\xbe\xd9\xd4\xcc\x9b\xe1\x7b\xc3\x21\x29\x6d\xb7\x90\xe0\x8a\x4b\x84\x20\x8a\x98\x40\x4d\x19\x93\x2c\x45\x1d\x40\x59\x7e\xed\xfc\xdf\x6e\x01\x65\x02\x65\xb9\x98\x74\x79\xb8\xbf\xb3\x5e\xdb\x2d\x84\x3f\xbf\x13\x6a\xc9\xc4\xc3\xfd\x1d\x94\xe5\xe7\x4f\x9f\x2b\x3b\xf3\xa3\xc6\x18\xf9\x1a\xf5\xad\x35\xba\x6f\xfe\xc0\x07\x14\x5a\xbc\x16\xa8\x37\xb5\x7b\x13\xc8\x8d\x64\x8a\xc7\x67\x8c\xc9\x46\xf8\xdb\x7a\x7f\x23\x46\x85\x81\x0f\x20\xf5\x90\xe7\xa8\x6b\x57\xbe\x02\x7c\x6d\x1f\x06\x2b\xae\xb9\x4c\xad\xcf\x8d\xf5\xa9\x26\x64\xc2\x5f\xaa\x51\xf8\x00\x81\xb2\x1b\xf1\x1f\xb0\x46\xbf\x6a\x55\xe4\x77\xec\x11\x85\x09\xbf\x29\x4d\x98\xfc\xc9\xb8\x36\xe1\x5f\x4c\x14\x68\x03\x3e\x2b\x2e\x21\x00\x8b\x0a\x75\xc8\x94\xe0\xca\x62\x85\x3f\xa9\x2c\x53\xb2\x76\x5e\x36\x63\x1d\xbc\x25\x94\xe5\xd5\x76\x0b\x6f\x9c\x9e\x5c\xe3\xf0\x1e\x33\xb5\x46\x37\xfa\x1f\x2c\x43\xd3\x30\x3a\x16\xbd\x4d\x7c\xd9\xfe\x9a\x90\x29\x41\x13\x6b\x9e\x13\x57\x32\x38\xc0\x31\xe1\x3b\xd5\x92\x46\x82\x1b\x6a\x4c\x35\x93\x29\x42\x08\x65\x59\xe7\x75\xb3\xd8\x0f\x0e\x79\xb2\xac\x5c\x57\x44\xda\xf4\xed\xbf\x5b\x68\x27\xd0\x24\x56\x07\xff\x2a\xa5\x22\x66\x73\x72\x20\x3b\xc3\xa7\xe1\x7e\x53\x85\x8e\xf1\xa6\x16\x13\x25\x6a\x46\x4a\xd7\x95\xb8\x18\x21\xea\x20\x05\x51\xc6\xf4\x4b\xa2\xde\xe4\x80\x8b\x85\x2f\x19\x9e\x59\x2f\xe6\xd3\xe1\x8b\xec\x45\xc8\x62\x9c\x11\x23\x58\xfc\x12\x26\xb8\x62\x85\xa0\x90\x38\x09\x6c\xa8\x20\xcc\x72\xc1\xc8\x5d\x9c\xe1\x54\x0d\xba\x38\x85\xb1\xed\x21\x1b\x83\x72\x9b\x90\x27\xde\x8a\x09\xf1\xc8\xe2\x97\x01\xde\x68\xfa\x16\x14\x3e\xe0\x98\xa1\xe0\xf2\xc5\x3b\x83\xb8\xc9\x80\x27\x81\x9f\x43\xae\xd1\xd6\x9a\xa7\x75\x27\xa1\x83\x8c\x55\x3d\xd8\x33\x65\x1e\x2b\x89\x99\x7a\xe6\x81\xbf\x7d\xa1\x85\x6f\xc6\xfe\x93\x5b\x29\x45\xf5\x8e\xd3\xa9\xc1\xae\x79\x6e\xa7\x96\x14\xb4\x69\x5d\x86\x0d\x6d\x5e\x39\x0e\x11\x63\xc1\x51\xd2\xe9\x05\x39\x85\xb8\xdf\x15\x4f\xd3\x6c\x88\xcb\xa5\x21\x26\x63\x34\x23\xb8\x83\x0e\x1e\x4e\xb3\xaa\x72\x93\xa2\xe4\xd8\x02\x67\x68\x0c\x4b\x4f\x5b\xdf\x03\xb0\xa1\x42\xcd\x86\x37\xd1\xd0\x46\x77\xb8\x45\x6f\x7f\x75\x36\xf0\x25\x7c\x81\x6b\xdb\x38\xab\x41\xa8\x07\xab\xd6\x79\x98\x11\xf7\x14\x50\x05\xb9\xee\xcc\x68\x24\xde\x3d\x1a\x25\xd6\x98\xf4\x22\xee\x86\xfd\x63\xee\x3c\x06\x51\xaf\x7d\x28\x35\x55\x1f\x9f\x5f\x4d\x8e\xea\x6f\x18\x3f\x31\x9a\xab\xf9\xe2\xa2\xdf\x01\xfd\xba\x07\xe5\x07\x2d\x06\x78\xa3\xfa\x4c\xa8\xde\xd3\x87\x54\x64\x37\xcb\xc9\x4e\x3a\x34\xcf\x99\xa6\xcd\x0c\x7b\x62\xa9\xaf\x35\x4b\x51\x52\xd4\xdf\xe2\xdc\xfa\x5a\xf3\x98\x94\x56\xb9\xd9\x97\x2d\x31\xc2\xc8\x2d\xb4\x4b\x2d\xcd\xeb\x05\x43\x56\x51\x12\xa7\x4d\x94\x70\x93\x0b\xb6\x89\x26\x4e\x53\xc7\x1b\xf7\x10\x39\x53\x92\x93\xb2\x84\x44\xa4\x94\x98\xb9\x25\x3a\x7b\x57\x61\x9e\xd4\x1a\xf5\x19\xce\x8f\x03\xa8\xff\xbe\x9e\xce\x53\x4e\xfe\xd5\x74\xbe\x62\x1a\x1e\xe9\x0f\x31\xb9\x3f\xd3\xcd\xd9\x53\xba\xa7\x39\xd9\x59\xec\xfb\x6b\xfa\xfc\x3b\x42\x07\xe7\x22\xef\x1c\x79\xbb\x2c\x12\x0a\x4c\x35\xcb\xc6\xa8\xfc\xdf\x92\x92\x70\x13\x2b\x9d\x9c\xa1\x11\xf5\x91\x2e\xec\xda\x63\xc2\x23\xbe\x5f\x96\xee\x77\xf3\x98\x19\x42\x96\x75\x9b\x69\x96\x31\xbd\x39\xa9\x4e\xfb\x58\xa7\x57\xfc\x00\xa9\xb9\xd9\xfb\xc8\xf4\x09\x66\x09\xd5\x79\xdd\xf6\xdd\x8a\xb5\xa1\x7d\x35\x1b\x09\x3e\x47\xbc\x67\xae\xd9\x59\x94\x73\x80\x7a\xd7\xe8\x0b\xe7\x8b\xea\x84\x3c\xca\x55\xae\xb9\xd2\xdc\x5e\x7e\xae\x9b\x83\xf4\x0f\xbb\x21\xb8\xb9\x85\x20\xd8\x9d\xaf\x77\xaf\x56\x9d\xd9\x5a\x1f\x00\x80\xca\xcf\xe0\x1a\x77\x7e\x5c\x26\xf8\xbe\x7b\xbb\x0b\xc1\xee\x51\xe0\x78\xf0\x15\x5c\xe1\x6b\xc7\x31\x88\x35\x27\x1e\x33\x11\x2c\x5b\xc3\x16\xbe\x4d\xeb\x16\x82\xdf\x78\xfa\xe4\x62\xa1\x30\x58\x01\x32\x99\xf4\x51\xdf\x98\x96\x5c\xa6\xc1\x12\xae\x24\x76\x80\x6a\x98\xe5\x91\x58\xbf\x63\xc2\x8b\xcc\x3f\x1a\x97\x2b\x65\x43\xd9\xd1\x7d\xa8\xa3\x61\xee\xd4\x5b\x2f\x86\x4c\x5a\x4d\xba\xbf\xeb\xcf\x35\x5d\x68\xc7\xcd\xd5\xa9\x2d\x8c\x41\xec\x59\x6a\xcd\x56\xcc\x43\xb5\xb3\x2b\xe7\xa5\xde\xf9\x14\x3c\xae\x62\x5f\xc9\x63\xca\xee\x91\xfa\x4f\x07\xad\xee\x49\x19\x6a\x97\x66\xf5\x69\xac\xd1\xb0\xe9\x25\x5f\xfa\x0b\x6d\xf7\xa1\xc5\x3a\xda\x7b\xaf\xf3\xfc\xe0\xc3\xe9\xec\x9b\xee\xf2\x6f\x00\x00\x00\xff\xff\x1d\xc6\xba\x31\x10\x1d\x00\x00"), }, "/templates/email.tmpl": &vfsgen۰CompressedFileInfo{ name: "email.tmpl", @@ -183,7 +183,6 @@ var Assets = func() http.FileSystem { fs["/static/favicon.ico"].(os.FileInfo), fs["/static/index.html"].(os.FileInfo), fs["/static/lib"].(os.FileInfo), - fs["/static/script.js"].(os.FileInfo), } fs["/static/lib"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ fs["/static/lib/bootstrap-4.0.0-alpha.6-dist"].(os.FileInfo), diff --git a/notify/jira/jira_test.go b/notify/jira/jira_test.go index 8e2576ca3e..ea0a998e58 100644 --- a/notify/jira/jira_test.go +++ b/notify/jira/jira_test.go @@ -93,6 +93,9 @@ func TestJiraTemplating(t *testing.T) { cfg: &config.JiraConfig{ Summary: `{{ template "jira.default.summary" . }}`, Description: `{{ template "jira.default.description" . }}`, + Fields: map[string]any{ + "customfield_14400": `{{ template "jira.host" . }}`, + }, }, retry: false, }, @@ -228,6 +231,7 @@ func TestJiraNotify(t *testing.T) { "customfield_10006": []map[any]any{{"value": "red"}, {"value": "blue"}, {"value": "green"}}, "customfield_10007": []map[any]any{{"value": "red"}, {"value": "blue"}, {"value": 0}}, "customfield_10008": []map[any]any{{"value": 0}, {"value": 1}, {"value": 2}}, + "customfield_14400": `{{ template "jira.host" . }}`, }, ReopenDuration: model.Duration(1 * time.Hour), ReopenTransition: "REOPEN", @@ -239,6 +243,7 @@ func TestJiraNotify(t *testing.T) { Labels: model.LabelSet{ "alertname": "test", "instance": "vm1", + "hostname": "host1.exmple.com", }, StartsAt: time.Now(), EndsAt: time.Now().Add(time.Hour), @@ -252,7 +257,7 @@ func TestJiraNotify(t *testing.T) { Key: "", Fields: &issueFields{ Summary: strings.Repeat("A", maxSummaryLenRunes-1) + "…", - Description: "\n\n# Alerts Firing:\n\nLabels:\n - alertname = test\n - instance = vm1\n\nAnnotations:\n\nSource: \n\n\n\n\n", + Description: "\n\n# Alerts Firing:\n\nLabels:\n - alertname = test\n - hostname = host1.exmple.com\n - instance = vm1\n\nAnnotations:\n\nSource: \n\n\n\n\n", Issuetype: &idNameValue{Name: "Incident"}, Labels: []string{"ALERT{6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b}", "alertmanager", "test"}, Project: &issueProject{Key: "OPS"}, @@ -260,6 +265,7 @@ func TestJiraNotify(t *testing.T) { }, customFieldAssetFn: func(t *testing.T, issue map[string]any) { require.Equal(t, "value", issue["customfield_10001"]) + require.Equal(t, "host1.exmple.com", issue["customfield_14400"]) require.Equal(t, float64(0), issue["customfield_10002"]) require.Equal(t, []any{float64(0)}, issue["customfield_10003"]) require.Equal(t, map[string]any{"value": "red"}, issue["customfield_10004"]) diff --git a/template/default.tmpl b/template/default.tmpl index 299bdecbb6..eb375dbbf2 100644 --- a/template/default.tmpl +++ b/template/default.tmpl @@ -197,3 +197,11 @@ Alerts Resolved: {{- end -}} {{- $priority -}} {{- end -}} + +{{ define "jira.host" }} +{{- with index .Alerts 0 -}} + {{- if .Labels.hostname -}} + {{- .Labels.hostname -}} + {{- end -}} + {{- end -}} +{{ end }} \ No newline at end of file