{"action":"created","comment":{"url":"https://api.github.com/repos/libopenstorage/openstorage/pulls/comments/213878377","pull_request_review_id":150807274,"id":213878377,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMzg3ODM3Nw==","diff_hunk":"@@ -0,0 +1,86 @@\n+package alerts\n+\n+import (\n+\t\"time\"\n+\n+\t\"github.com/libopenstorage/openstorage/api\"\n+\t\"github.com/portworx/kvdb\"\n+)\n+\n+// NewManager obtains instance of Manager for alerts management.\n+func NewManager(kv kvdb.Kvdb) Manager {\n+\treturn newManager(kv)\n+}\n+\n+// Filter API\n+\n+// NewQueryResourceTypeFilter creates a filter that matches on <resourceType>\n+func NewQueryResourceTypeFilter(resourceType api.ResourceType) Filter {\n+\treturn &filter{filterType: QueryResourceTypeFilter, value: resourceType}\n+}\n+\n+// NewQueryAlertTypeFilter creates a filter that matches on <resourceType>/<alertType>\n+func NewQueryAlertTypeFilter(alertType int64, resourceType api.ResourceType) Filter {\n+\treturn &filter{filterType: QueryAlertTypeFilter, value: alertInfo{\n+\t\talertType: alertType, resourceType: resourceType}}\n+}\n+\n+// NewQueryResourceIDFilter creates a filter that matches on <resourceType>/<alertType>/<resourceID>\n+func NewQueryResourceIDFilter(resourceID string, alertType int64, resourceType api.ResourceType) Filter {\n+\treturn &filter{filterType: QueryResourceIDFilter, value: alertInfo{\n+\t\tresourceID: resourceID, alertType: alertType, resourceType: resourceType}}\n+}\n+\n+// NewTimeFilter creates a filter that matches on alert raised in a given time window.\n+func NewTimeFilter(start, stop time.Time) Filter {\n+\treturn &filter{filterType: TimeFilter, value: timeZone{start: start, stop: stop}}\n+}\n+\n+// NewAlertTypeFilter provides a filter that matches on alerty type.\n+// Please note that if you are filtering for alert types for a given resource type, it is better\n+// to use NewQueryAlertTypeFilter instead of this filter since it is more efficient in terms of\n+// kvdb access.\n+func NewAlertTypeFilter(alertType int64) Filter {","path":"alerts/api.go","position":43,"original_position":43,"commit_id":"002dcde7eebf2655db811037b413322be3063eb5","original_commit_id":"7944faef61458094678dbea3bd2e4acd72d23587","user":{"login":"sdeoras","id":16372009,"node_id":"MDQ6VXNlcjE2MzcyMDA5","avatar_url":"https://avatars2.githubusercontent.com/u/16372009?v=4","gravatar_id":"","url":"https://api.github.com/users/sdeoras","html_url":"https://github.com/sdeoras","followers_url":"https://api.github.com/users/sdeoras/followers","following_url":"https://api.github.com/users/sdeoras/following{/other_user}","gists_url":"https://api.github.com/users/sdeoras/gists{/gist_id}","starred_url":"https://api.github.com/users/sdeoras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdeoras/subscriptions","organizations_url":"https://api.github.com/users/sdeoras/orgs","repos_url":"https://api.github.com/users/sdeoras/repos","events_url":"https://api.github.com/users/sdeoras/events{/privacy}","received_events_url":"https://api.github.com/users/sdeoras/received_events","type":"User","site_admin":false},"body":"yup, makes sense since we are enforcing alert type and resource type to be always available as a pair of info.","created_at":"2018-08-30T01:06:14Z","updated_at":"2018-08-30T01:06:14Z","html_url":"https://github.com/libopenstorage/openstorage/pull/575#discussion_r213878377","pull_request_url":"https://api.github.com/repos/libopenstorage/openstorage/pulls/575","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/libopenstorage/openstorage/pulls/comments/213878377"},"html":{"href":"https://github.com/libopenstorage/openstorage/pull/575#discussion_r213878377"},"pull_request":{"href":"https://api.github.com/repos/libopenstorage/openstorage/pulls/575"}},"in_reply_to_id":213823559},"pull_request":{"url":"https://api.github.com/repos/libopenstorage/openstorage/pulls/575","id":209373128,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA5MzczMTI4","html_url":"https://github.com/libopenstorage/openstorage/pull/575","diff_url":"https://github.com/libopenstorage/openstorage/pull/575.diff","patch_url":"https://github.com/libopenstorage/openstorage/pull/575.patch","issue_url":"https://api.github.com/repos/libopenstorage/openstorage/issues/575","number":575,"state":"open","locked":false,"title":"Alerts Interface for Expressing Conditionals","user":{"login":"sdeoras","id":16372009,"node_id":"MDQ6VXNlcjE2MzcyMDA5","avatar_url":"https://avatars2.githubusercontent.com/u/16372009?v=4","gravatar_id":"","url":"https://api.github.com/users/sdeoras","html_url":"https://github.com/sdeoras","followers_url":"https://api.github.com/users/sdeoras/followers","following_url":"https://api.github.com/users/sdeoras/following{/other_user}","gists_url":"https://api.github.com/users/sdeoras/gists{/gist_id}","starred_url":"https://api.github.com/users/sdeoras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdeoras/subscriptions","organizations_url":"https://api.github.com/users/sdeoras/orgs","repos_url":"https://api.github.com/users/sdeoras/repos","events_url":"https://api.github.com/users/sdeoras/events{/privacy}","received_events_url":"https://api.github.com/users/sdeoras/received_events","type":"User","site_admin":false},"body":"\r\n**What this PR does / why we need it**:\r\nThis pr is to redesign alerts interface to be able to express interrelations among alerts using filters, actions and rules. See tests for more details.\r\n\r\n**Which issue(s) this PR fixes** (optional)\r\nCloses #572 \r\n\r\n**Special notes for your reviewer**:\r\n\r\n","created_at":"2018-08-19T18:33:19Z","updated_at":"2018-08-30T01:06:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"43598c0c9acc5a53d305987ba0ba2876f4bde6f2","assignee":null,"assignees":[],"requested_reviewers":[{"login":"lpabon","id":3880001,"node_id":"MDQ6VXNlcjM4ODAwMDE=","avatar_url":"https://avatars2.githubusercontent.com/u/3880001?v=4","gravatar_id":"","url":"https://api.github.com/users/lpabon","html_url":"https://github.com/lpabon","followers_url":"https://api.github.com/users/lpabon/followers","following_url":"https://api.github.com/users/lpabon/following{/other_user}","gists_url":"https://api.github.com/users/lpabon/gists{/gist_id}","starred_url":"https://api.github.com/users/lpabon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpabon/subscriptions","organizations_url":"https://api.github.com/users/lpabon/orgs","repos_url":"https://api.github.com/users/lpabon/repos","events_url":"https://api.github.com/users/lpabon/events{/privacy}","received_events_url":"https://api.github.com/users/lpabon/received_events","type":"User","site_admin":false},{"login":"jvinod","id":10396455,"node_id":"MDQ6VXNlcjEwMzk2NDU1","avatar_url":"https://avatars0.githubusercontent.com/u/10396455?v=4","gravatar_id":"","url":"https://api.github.com/users/jvinod","html_url":"https://github.com/jvinod","followers_url":"https://api.github.com/users/jvinod/followers","following_url":"https://api.github.com/users/jvinod/following{/other_user}","gists_url":"https://api.github.com/users/jvinod/gists{/gist_id}","starred_url":"https://api.github.com/users/jvinod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvinod/subscriptions","organizations_url":"https://api.github.com/users/jvinod/orgs","repos_url":"https://api.github.com/users/jvinod/repos","events_url":"https://api.github.com/users/jvinod/events{/privacy}","received_events_url":"https://api.github.com/users/jvinod/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/libopenstorage/openstorage/pulls/575/commits","review_comments_url":"https://api.github.com/repos/libopenstorage/openstorage/pulls/575/comments","review_comment_url":"https://api.github.com/repos/libopenstorage/openstorage/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libopenstorage/openstorage/issues/575/comments","statuses_url":"https://api.github.com/repos/libopenstorage/openstorage/statuses/002dcde7eebf2655db811037b413322be3063eb5","head":{"label":"libopenstorage:alerts-update-3","ref":"alerts-update-3","sha":"002dcde7eebf2655db811037b413322be3063eb5","user":{"login":"libopenstorage","id":13478636,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDc4NjM2","avatar_url":"https://avatars0.githubusercontent.com/u/13478636?v=4","gravatar_id":"","url":"https://api.github.com/users/libopenstorage","html_url":"https://github.com/libopenstorage","followers_url":"https://api.github.com/users/libopenstorage/followers","following_url":"https://api.github.com/users/libopenstorage/following{/other_user}","gists_url":"https://api.github.com/users/libopenstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/libopenstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libopenstorage/subscriptions","organizations_url":"https://api.github.com/users/libopenstorage/orgs","repos_url":"https://api.github.com/users/libopenstorage/repos","events_url":"https://api.github.com/users/libopenstorage/events{/privacy}","received_events_url":"https://api.github.com/users/libopenstorage/received_events","type":"Organization","site_admin":false},"repo":{"id":39651750,"node_id":"MDEwOlJlcG9zaXRvcnkzOTY1MTc1MA==","name":"openstorage","full_name":"libopenstorage/openstorage","owner":{"login":"libopenstorage","id":13478636,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDc4NjM2","avatar_url":"https://avatars0.githubusercontent.com/u/13478636?v=4","gravatar_id":"","url":"https://api.github.com/users/libopenstorage","html_url":"https://github.com/libopenstorage","followers_url":"https://api.github.com/users/libopenstorage/followers","following_url":"https://api.github.com/users/libopenstorage/following{/other_user}","gists_url":"https://api.github.com/users/libopenstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/libopenstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libopenstorage/subscriptions","organizations_url":"https://api.github.com/users/libopenstorage/orgs","repos_url":"https://api.github.com/users/libopenstorage/repos","events_url":"https://api.github.com/users/libopenstorage/events{/privacy}","received_events_url":"https://api.github.com/users/libopenstorage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libopenstorage/openstorage","description":"A multi-host clustered implementation of the open storage specification","fork":false,"url":"https://api.github.com/repos/libopenstorage/openstorage","forks_url":"https://api.github.com/repos/libopenstorage/openstorage/forks","keys_url":"https://api.github.com/repos/libopenstorage/openstorage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libopenstorage/openstorage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libopenstorage/openstorage/teams","hooks_url":"https://api.github.com/repos/libopenstorage/openstorage/hooks","issue_events_url":"https://api.github.com/repos/libopenstorage/openstorage/issues/events{/number}","events_url":"https://api.github.com/repos/libopenstorage/openstorage/events","assignees_url":"https://api.github.com/repos/libopenstorage/openstorage/assignees{/user}","branches_url":"https://api.github.com/repos/libopenstorage/openstorage/branches{/branch}","tags_url":"https://api.github.com/repos/libopenstorage/openstorage/tags","blobs_url":"https://api.github.com/repos/libopenstorage/openstorage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libopenstorage/openstorage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libopenstorage/openstorage/git/refs{/sha}","trees_url":"https://api.github.com/repos/libopenstorage/openstorage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libopenstorage/openstorage/statuses/{sha}","languages_url":"https://api.github.com/repos/libopenstorage/openstorage/languages","stargazers_url":"https://api.github.com/repos/libopenstorage/openstorage/stargazers","contributors_url":"https://api.github.com/repos/libopenstorage/openstorage/contributors","subscribers_url":"https://api.github.com/repos/libopenstorage/openstorage/subscribers","subscription_url":"https://api.github.com/repos/libopenstorage/openstorage/subscription","commits_url":"https://api.github.com/repos/libopenstorage/openstorage/commits{/sha}","git_commits_url":"https://api.github.com/repos/libopenstorage/openstorage/git/commits{/sha}","comments_url":"https://api.github.com/repos/libopenstorage/openstorage/comments{/number}","issue_comment_url":"https://api.github.com/repos/libopenstorage/openstorage/issues/comments{/number}","contents_url":"https://api.github.com/repos/libopenstorage/openstorage/contents/{+path}","compare_url":"https://api.github.com/repos/libopenstorage/openstorage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libopenstorage/openstorage/merges","archive_url":"https://api.github.com/repos/libopenstorage/openstorage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libopenstorage/openstorage/downloads","issues_url":"https://api.github.com/repos/libopenstorage/openstorage/issues{/number}","pulls_url":"https://api.github.com/repos/libopenstorage/openstorage/pulls{/number}","milestones_url":"https://api.github.com/repos/libopenstorage/openstorage/milestones{/number}","notifications_url":"https://api.github.com/repos/libopenstorage/openstorage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libopenstorage/openstorage/labels{/name}","releases_url":"https://api.github.com/repos/libopenstorage/openstorage/releases{/id}","deployments_url":"https://api.github.com/repos/libopenstorage/openstorage/deployments","created_at":"2015-07-24T19:01:34Z","updated_at":"2018-08-29T19:07:19Z","pushed_at":"2018-08-30T00:14:15Z","git_url":"git://github.com/libopenstorage/openstorage.git","ssh_url":"git@github.com:libopenstorage/openstorage.git","clone_url":"https://github.com/libopenstorage/openstorage.git","svn_url":"https://github.com/libopenstorage/openstorage","homepage":"","size":23809,"stargazers_count":298,"watchers_count":298,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"archived":false,"open_issues_count":77,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":56,"open_issues":77,"watchers":298,"default_branch":"master"}},"base":{"label":"libopenstorage:master","ref":"master","sha":"acdb00bb4ab7ca3bd1d2408a1b9416a3cffce851","user":{"login":"libopenstorage","id":13478636,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDc4NjM2","avatar_url":"https://avatars0.githubusercontent.com/u/13478636?v=4","gravatar_id":"","url":"https://api.github.com/users/libopenstorage","html_url":"https://github.com/libopenstorage","followers_url":"https://api.github.com/users/libopenstorage/followers","following_url":"https://api.github.com/users/libopenstorage/following{/other_user}","gists_url":"https://api.github.com/users/libopenstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/libopenstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libopenstorage/subscriptions","organizations_url":"https://api.github.com/users/libopenstorage/orgs","repos_url":"https://api.github.com/users/libopenstorage/repos","events_url":"https://api.github.com/users/libopenstorage/events{/privacy}","received_events_url":"https://api.github.com/users/libopenstorage/received_events","type":"Organization","site_admin":false},"repo":{"id":39651750,"node_id":"MDEwOlJlcG9zaXRvcnkzOTY1MTc1MA==","name":"openstorage","full_name":"libopenstorage/openstorage","owner":{"login":"libopenstorage","id":13478636,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDc4NjM2","avatar_url":"https://avatars0.githubusercontent.com/u/13478636?v=4","gravatar_id":"","url":"https://api.github.com/users/libopenstorage","html_url":"https://github.com/libopenstorage","followers_url":"https://api.github.com/users/libopenstorage/followers","following_url":"https://api.github.com/users/libopenstorage/following{/other_user}","gists_url":"https://api.github.com/users/libopenstorage/gists{/gist_id}","starred_url":"https://api.github.com/users/libopenstorage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libopenstorage/subscriptions","organizations_url":"https://api.github.com/users/libopenstorage/orgs","repos_url":"https://api.github.com/users/libopenstorage/repos","events_url":"https://api.github.com/users/libopenstorage/events{/privacy}","received_events_url":"https://api.github.com/users/libopenstorage/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libopenstorage/openstorage","description":"A multi-host clustered implementation of the open storage specification","fork":false,"url":"https://api.github.com/repos/libopenstorage/openstorage","forks_url":"https://api.github.com/repos/libopenstorage/openstorage/forks","keys_url":"https://api.github.com/repos/libopenstorage/openstorage/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libopenstorage/openstorage/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libopenstorage/openstorage/teams","hooks_url":"https://api.github.com/repos/libopenstorage/openstorage/hooks","issue_events_url":"https://api.github.com/repos/libopenstorage/openstorage/issues/events{/number}","events_url":"https://api.github.com/repos/libopenstorage/openstorage/events","assignees_url":"https://api.github.com/repos/libopenstorage/openstorage/assignees{/user}","branches_url":"https://api.github.com/repos/libopenstorage/openstorage/branches{/branch}","tags_url":"https://api.github.com/repos/libopenstorage/openstorage/tags","blobs_url":"https://api.github.com/repos/libopenstorage/openstorage/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libopenstorage/openstorage/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libopenstorage/openstorage/git/refs{/sha}","trees_url":"https://api.github.com/repos/libopenstorage/openstorage/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libopenstorage/openstorage/statuses/{sha}","languages_url":"https://api.github.com/repos/libopenstorage/openstorage/languages","stargazers_url":"https://api.github.com/repos/libopenstorage/openstorage/stargazers","contributors_url":"https://api.github.com/repos/libopenstorage/openstorage/contributors","subscribers_url":"https://api.github.com/repos/libopenstorage/openstorage/subscribers","subscription_url":"https://api.github.com/repos/libopenstorage/openstorage/subscription","commits_url":"https://api.github.com/repos/libopenstorage/openstorage/commits{/sha}","git_commits_url":"https://api.github.com/repos/libopenstorage/openstorage/git/commits{/sha}","comments_url":"https://api.github.com/repos/libopenstorage/openstorage/comments{/number}","issue_comment_url":"https://api.github.com/repos/libopenstorage/openstorage/issues/comments{/number}","contents_url":"https://api.github.com/repos/libopenstorage/openstorage/contents/{+path}","compare_url":"https://api.github.com/repos/libopenstorage/openstorage/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libopenstorage/openstorage/merges","archive_url":"https://api.github.com/repos/libopenstorage/openstorage/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libopenstorage/openstorage/downloads","issues_url":"https://api.github.com/repos/libopenstorage/openstorage/issues{/number}","pulls_url":"https://api.github.com/repos/libopenstorage/openstorage/pulls{/number}","milestones_url":"https://api.github.com/repos/libopenstorage/openstorage/milestones{/number}","notifications_url":"https://api.github.com/repos/libopenstorage/openstorage/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libopenstorage/openstorage/labels{/name}","releases_url":"https://api.github.com/repos/libopenstorage/openstorage/releases{/id}","deployments_url":"https://api.github.com/repos/libopenstorage/openstorage/deployments","created_at":"2015-07-24T19:01:34Z","updated_at":"2018-08-29T19:07:19Z","pushed_at":"2018-08-30T00:14:15Z","git_url":"git://github.com/libopenstorage/openstorage.git","ssh_url":"git@github.com:libopenstorage/openstorage.git","clone_url":"https://github.com/libopenstorage/openstorage.git","svn_url":"https://github.com/libopenstorage/openstorage","homepage":"","size":23809,"stargazers_count":298,"watchers_count":298,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":56,"mirror_url":null,"archived":false,"open_issues_count":77,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":56,"open_issues":77,"watchers":298,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libopenstorage/openstorage/pulls/575"},"html":{"href":"https://github.com/libopenstorage/openstorage/pull/575"},"issue":{"href":"https://api.github.com/repos/libopenstorage/openstorage/issues/575"},"comments":{"href":"https://api.github.com/repos/libopenstorage/openstorage/issues/575/comments"},"review_comments":{"href":"https://api.github.com/repos/libopenstorage/openstorage/pulls/575/comments"},"review_comment":{"href":"https://api.github.com/repos/libopenstorage/openstorage/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libopenstorage/openstorage/pulls/575/commits"},"statuses":{"href":"https://api.github.com/repos/libopenstorage/openstorage/statuses/002dcde7eebf2655db811037b413322be3063eb5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sdeoras"}}