{"action":"closed","number":1737,"pull_request":{"url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/1737","id":70132161,"html_url":"https://github.com/bosun-monitor/bosun/pull/1737","diff_url":"https://github.com/bosun-monitor/bosun/pull/1737.diff","patch_url":"https://github.com/bosun-monitor/bosun/pull/1737.patch","issue_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/1737","number":1737,"state":"closed","locked":false,"title":"cmd/bosun: alternate templates for POST notifications","user":{"login":"mkuzmin","id":712402,"avatar_url":"https://avatars.githubusercontent.com/u/712402?v=3","gravatar_id":"","url":"https://api.github.com/users/mkuzmin","html_url":"https://github.com/mkuzmin","followers_url":"https://api.github.com/users/mkuzmin/followers","following_url":"https://api.github.com/users/mkuzmin/following{/other_user}","gists_url":"https://api.github.com/users/mkuzmin/gists{/gist_id}","starred_url":"https://api.github.com/users/mkuzmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkuzmin/subscriptions","organizations_url":"https://api.github.com/users/mkuzmin/orgs","repos_url":"https://api.github.com/users/mkuzmin/repos","events_url":"https://api.github.com/users/mkuzmin/events{/privacy}","received_events_url":"https://api.github.com/users/mkuzmin/received_events","type":"User","site_admin":false},"body":"This is an attempt to support rich Slack notifications with markup and weblinks:\n![slack](https://cloud.githubusercontent.com/assets/712402/15276348/ff4655a6-1aed-11e6-869b-4ee30e9d6777.png)\n\nTemplates should contain JSON code, but here are the current issues:\n- if the code is put into `subject`, Bosun shows ugly incident titles on a web page: https://github.com/bosun-monitor/bosun/issues/1096#issue-90477041.\n- `useBody` setting does not help - HTML markup is automatically added to JSON content, and Slack servers do not accept such calls.\n- Acknowledgement notifications do not work.\n\nIdeally, we need additional variable resolution in notification settings: #689 & #1726. But this is a complex feature, I found no easy way how to implement it.\n\nInstead, I've added two more settings: \n- `postBody` provide alternate template for common notifications.\n- `actionBody` is used for action notifications.\n\nUnfortunately, they have to be configured in different places.\n\nHere is a full example:\n\n```\ntemplate lowDatastoreSpace {\n    subject = `Datastore free space = {{ bytes (.Eval .Alert.Vars.freeSpace)}}`\n    body = `{{ .Graph .Alert.Vars.metric }}`\n    postBody = `{ \"attachments\": [{\n        \"color\": \"danger\",\n        \"title\": \"Incident #{{ .Id }}\",\n        \"title_link\": \"{{ .Incident }}\",\n        \"text\": \"Datastore free space = {{ bytes (.Eval .Alert.Vars.freeSpace)}}\",\n        \"fallback\": \"Incident #{{ .Id }}: Datastore free space = {{ bytes (.Eval .Alert.Vars.freeSpace)}}\"\n    }]}`\n}\n\nnotification slack {\n    post = https://hooks.slack.com/services/<ID>\n    actionBody = `{ \"attachments\": [{\"color\": \"good\", \"text\": \"{{ . }}\"}] }`\n}\n```\n\nIf anyone wants to try, here are [binaries](https://github.com/mkuzmin/bosun/releases/tag/0.5.dev-mkuzmin1) and a [Docker image](https://hub.docker.com/r/mkuzmin/bosun/).\n","created_at":"2016-05-15T20:28:18Z","updated_at":"2016-11-12T17:43:25Z","closed_at":"2016-11-12T17:43:25Z","merged_at":null,"merge_commit_sha":"c14794458341ab03e5305c3d3e7abb1f613ca6ee","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/1737/commits","review_comments_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/1737/comments","review_comment_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/1737/comments","statuses_url":"https://api.github.com/repos/bosun-monitor/bosun/statuses/12ca6f07dfae8636c1724e75d006d0e78de28405","head":{"label":"mkuzmin:post-body","ref":"post-body","sha":"12ca6f07dfae8636c1724e75d006d0e78de28405","user":{"login":"mkuzmin","id":712402,"avatar_url":"https://avatars.githubusercontent.com/u/712402?v=3","gravatar_id":"","url":"https://api.github.com/users/mkuzmin","html_url":"https://github.com/mkuzmin","followers_url":"https://api.github.com/users/mkuzmin/followers","following_url":"https://api.github.com/users/mkuzmin/following{/other_user}","gists_url":"https://api.github.com/users/mkuzmin/gists{/gist_id}","starred_url":"https://api.github.com/users/mkuzmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkuzmin/subscriptions","organizations_url":"https://api.github.com/users/mkuzmin/orgs","repos_url":"https://api.github.com/users/mkuzmin/repos","events_url":"https://api.github.com/users/mkuzmin/events{/privacy}","received_events_url":"https://api.github.com/users/mkuzmin/received_events","type":"User","site_admin":false},"repo":{"id":58800767,"name":"bosun","full_name":"mkuzmin/bosun","owner":{"login":"mkuzmin","id":712402,"avatar_url":"https://avatars.githubusercontent.com/u/712402?v=3","gravatar_id":"","url":"https://api.github.com/users/mkuzmin","html_url":"https://github.com/mkuzmin","followers_url":"https://api.github.com/users/mkuzmin/followers","following_url":"https://api.github.com/users/mkuzmin/following{/other_user}","gists_url":"https://api.github.com/users/mkuzmin/gists{/gist_id}","starred_url":"https://api.github.com/users/mkuzmin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkuzmin/subscriptions","organizations_url":"https://api.github.com/users/mkuzmin/orgs","repos_url":"https://api.github.com/users/mkuzmin/repos","events_url":"https://api.github.com/users/mkuzmin/events{/privacy}","received_events_url":"https://api.github.com/users/mkuzmin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mkuzmin/bosun","description":"Time Series Alerting Framework","fork":true,"url":"https://api.github.com/repos/mkuzmin/bosun","forks_url":"https://api.github.com/repos/mkuzmin/bosun/forks","keys_url":"https://api.github.com/repos/mkuzmin/bosun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mkuzmin/bosun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mkuzmin/bosun/teams","hooks_url":"https://api.github.com/repos/mkuzmin/bosun/hooks","issue_events_url":"https://api.github.com/repos/mkuzmin/bosun/issues/events{/number}","events_url":"https://api.github.com/repos/mkuzmin/bosun/events","assignees_url":"https://api.github.com/repos/mkuzmin/bosun/assignees{/user}","branches_url":"https://api.github.com/repos/mkuzmin/bosun/branches{/branch}","tags_url":"https://api.github.com/repos/mkuzmin/bosun/tags","blobs_url":"https://api.github.com/repos/mkuzmin/bosun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mkuzmin/bosun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mkuzmin/bosun/git/refs{/sha}","trees_url":"https://api.github.com/repos/mkuzmin/bosun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mkuzmin/bosun/statuses/{sha}","languages_url":"https://api.github.com/repos/mkuzmin/bosun/languages","stargazers_url":"https://api.github.com/repos/mkuzmin/bosun/stargazers","contributors_url":"https://api.github.com/repos/mkuzmin/bosun/contributors","subscribers_url":"https://api.github.com/repos/mkuzmin/bosun/subscribers","subscription_url":"https://api.github.com/repos/mkuzmin/bosun/subscription","commits_url":"https://api.github.com/repos/mkuzmin/bosun/commits{/sha}","git_commits_url":"https://api.github.com/repos/mkuzmin/bosun/git/commits{/sha}","comments_url":"https://api.github.com/repos/mkuzmin/bosun/comments{/number}","issue_comment_url":"https://api.github.com/repos/mkuzmin/bosun/issues/comments{/number}","contents_url":"https://api.github.com/repos/mkuzmin/bosun/contents/{+path}","compare_url":"https://api.github.com/repos/mkuzmin/bosun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mkuzmin/bosun/merges","archive_url":"https://api.github.com/repos/mkuzmin/bosun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mkuzmin/bosun/downloads","issues_url":"https://api.github.com/repos/mkuzmin/bosun/issues{/number}","pulls_url":"https://api.github.com/repos/mkuzmin/bosun/pulls{/number}","milestones_url":"https://api.github.com/repos/mkuzmin/bosun/milestones{/number}","notifications_url":"https://api.github.com/repos/mkuzmin/bosun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mkuzmin/bosun/labels{/name}","releases_url":"https://api.github.com/repos/mkuzmin/bosun/releases{/id}","deployments_url":"https://api.github.com/repos/mkuzmin/bosun/deployments","created_at":"2016-05-14T09:49:23Z","updated_at":"2016-05-14T09:49:25Z","pushed_at":"2016-05-15T21:09:58Z","git_url":"git://github.com/mkuzmin/bosun.git","ssh_url":"git@github.com:mkuzmin/bosun.git","clone_url":"https://github.com/mkuzmin/bosun.git","svn_url":"https://github.com/mkuzmin/bosun","homepage":"http://bosun.org","size":37145,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bosun-monitor:master","ref":"master","sha":"af0227fedcb8d1d9fdcd1558b4a4694ea7b1dc2d","user":{"login":"bosun-monitor","id":9555242,"avatar_url":"https://avatars.githubusercontent.com/u/9555242?v=3","gravatar_id":"","url":"https://api.github.com/users/bosun-monitor","html_url":"https://github.com/bosun-monitor","followers_url":"https://api.github.com/users/bosun-monitor/followers","following_url":"https://api.github.com/users/bosun-monitor/following{/other_user}","gists_url":"https://api.github.com/users/bosun-monitor/gists{/gist_id}","starred_url":"https://api.github.com/users/bosun-monitor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bosun-monitor/subscriptions","organizations_url":"https://api.github.com/users/bosun-monitor/orgs","repos_url":"https://api.github.com/users/bosun-monitor/repos","events_url":"https://api.github.com/users/bosun-monitor/events{/privacy}","received_events_url":"https://api.github.com/users/bosun-monitor/received_events","type":"Organization","site_admin":false},"repo":{"id":14410778,"name":"bosun","full_name":"bosun-monitor/bosun","owner":{"login":"bosun-monitor","id":9555242,"avatar_url":"https://avatars.githubusercontent.com/u/9555242?v=3","gravatar_id":"","url":"https://api.github.com/users/bosun-monitor","html_url":"https://github.com/bosun-monitor","followers_url":"https://api.github.com/users/bosun-monitor/followers","following_url":"https://api.github.com/users/bosun-monitor/following{/other_user}","gists_url":"https://api.github.com/users/bosun-monitor/gists{/gist_id}","starred_url":"https://api.github.com/users/bosun-monitor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bosun-monitor/subscriptions","organizations_url":"https://api.github.com/users/bosun-monitor/orgs","repos_url":"https://api.github.com/users/bosun-monitor/repos","events_url":"https://api.github.com/users/bosun-monitor/events{/privacy}","received_events_url":"https://api.github.com/users/bosun-monitor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bosun-monitor/bosun","description":"Time Series Alerting Framework","fork":false,"url":"https://api.github.com/repos/bosun-monitor/bosun","forks_url":"https://api.github.com/repos/bosun-monitor/bosun/forks","keys_url":"https://api.github.com/repos/bosun-monitor/bosun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bosun-monitor/bosun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bosun-monitor/bosun/teams","hooks_url":"https://api.github.com/repos/bosun-monitor/bosun/hooks","issue_events_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/events{/number}","events_url":"https://api.github.com/repos/bosun-monitor/bosun/events","assignees_url":"https://api.github.com/repos/bosun-monitor/bosun/assignees{/user}","branches_url":"https://api.github.com/repos/bosun-monitor/bosun/branches{/branch}","tags_url":"https://api.github.com/repos/bosun-monitor/bosun/tags","blobs_url":"https://api.github.com/repos/bosun-monitor/bosun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bosun-monitor/bosun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bosun-monitor/bosun/git/refs{/sha}","trees_url":"https://api.github.com/repos/bosun-monitor/bosun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bosun-monitor/bosun/statuses/{sha}","languages_url":"https://api.github.com/repos/bosun-monitor/bosun/languages","stargazers_url":"https://api.github.com/repos/bosun-monitor/bosun/stargazers","contributors_url":"https://api.github.com/repos/bosun-monitor/bosun/contributors","subscribers_url":"https://api.github.com/repos/bosun-monitor/bosun/subscribers","subscription_url":"https://api.github.com/repos/bosun-monitor/bosun/subscription","commits_url":"https://api.github.com/repos/bosun-monitor/bosun/commits{/sha}","git_commits_url":"https://api.github.com/repos/bosun-monitor/bosun/git/commits{/sha}","comments_url":"https://api.github.com/repos/bosun-monitor/bosun/comments{/number}","issue_comment_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/comments{/number}","contents_url":"https://api.github.com/repos/bosun-monitor/bosun/contents/{+path}","compare_url":"https://api.github.com/repos/bosun-monitor/bosun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bosun-monitor/bosun/merges","archive_url":"https://api.github.com/repos/bosun-monitor/bosun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bosun-monitor/bosun/downloads","issues_url":"https://api.github.com/repos/bosun-monitor/bosun/issues{/number}","pulls_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls{/number}","milestones_url":"https://api.github.com/repos/bosun-monitor/bosun/milestones{/number}","notifications_url":"https://api.github.com/repos/bosun-monitor/bosun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bosun-monitor/bosun/labels{/name}","releases_url":"https://api.github.com/repos/bosun-monitor/bosun/releases{/id}","deployments_url":"https://api.github.com/repos/bosun-monitor/bosun/deployments","created_at":"2013-11-15T00:12:27Z","updated_at":"2016-11-10T13:38:53Z","pushed_at":"2016-11-09T00:50:44Z","git_url":"git://github.com/bosun-monitor/bosun.git","ssh_url":"git@github.com:bosun-monitor/bosun.git","clone_url":"https://github.com/bosun-monitor/bosun.git","svn_url":"https://github.com/bosun-monitor/bosun","homepage":"http://bosun.org","size":68696,"stargazers_count":1995,"watchers_count":1995,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":321,"mirror_url":null,"open_issues_count":286,"forks":321,"open_issues":286,"watchers":1995,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/1737"},"html":{"href":"https://github.com/bosun-monitor/bosun/pull/1737"},"issue":{"href":"https://api.github.com/repos/bosun-monitor/bosun/issues/1737"},"comments":{"href":"https://api.github.com/repos/bosun-monitor/bosun/issues/1737/comments"},"review_comments":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/1737/comments"},"review_comment":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/1737/commits"},"statuses":{"href":"https://api.github.com/repos/bosun-monitor/bosun/statuses/12ca6f07dfae8636c1724e75d006d0e78de28405"}},"merged":false,"mergeable":false,"mergeable_state":"dirty","merged_by":null,"comments":8,"review_comments":0,"commits":2,"additions":80,"deletions":23,"changed_files":6}}
{"actor":{"display_login":"mkuzmin"}}