{"action":"created","comment":{"url":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/comments/68061322","id":68061322,"diff_hunk":"@@ -35,6 +43,101 @@ def __init__(self, *args, **kwargs):\n         self.consumer.daemon = True\n         self.consumer.start()\n \n+\n+    def cmd_show(self, event, action):\n+        \"\"\"Show information on projects or projects being tracked.\n+        Show which projects are being tracked. 'prometheus show tracking'\n+        Show which proejcts are recognised so they could be tracked. 'prometheus show projects'\n+        \"\"\"\n+        if action in self.TRACKING:\n+            return self._get_tracking(event[\"room_id\"])\n+        elif action == \"projects\":\n+            projects = self.store.get(\"known_projects\")\n+            return \"Available projects: %s\" % json.dumps(projects)\n+        else:\n+            return \"Invalid arg '%s'.\\n %s\" % (action, self.cmd_show.__doc__)\n+\n+    @admin_only\n+    def cmd_track(self, event, *args):\n+        \"\"\"Track projects. 'prometheus track Foo \"bar with spaces\"'\"\"\"\n+        if len(args) == 0:\n+            return self._get_tracking(event[\"room_id\"])\n+\n+        for project in args:\n+            if not project in self.store.get(\"known_projects\"):\n+                return \"Unknown project name: %s.\" % project\n+\n+        self._send_track_event(event[\"room_id\"], args)\n+\n+        return \"Prometheus notifications for projects %s will be displayed when they fail.\" % (args)\n+\n+    @admin_only\n+    def cmd_add(self, event, project):\n+        \"\"\"Add a project for tracking. 'prometheus add projectName'\"\"\"\n+        if project not in self.store.get(\"known_projects\"):\n+            return \"Unknown project name: %s.\" % project\n+\n+        try:\n+            room_projects = self.rooms.get_content(\n+                event[\"room_id\"],\n+                PrometheusPlugin.TYPE_TRACK)[\"projects\"]","path":"plugins/prometheus.py","position":63,"original_position":63,"commit_id":"69bcdc192572d824ca7f9b1f2231cecaeb9e71b0","original_commit_id":"69bcdc192572d824ca7f9b1f2231cecaeb9e71b0","user":{"login":"mweinelt","id":131599,"avatar_url":"https://avatars.githubusercontent.com/u/131599?v=3","gravatar_id":"","url":"https://api.github.com/users/mweinelt","html_url":"https://github.com/mweinelt","followers_url":"https://api.github.com/users/mweinelt/followers","following_url":"https://api.github.com/users/mweinelt/following{/other_user}","gists_url":"https://api.github.com/users/mweinelt/gists{/gist_id}","starred_url":"https://api.github.com/users/mweinelt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mweinelt/subscriptions","organizations_url":"https://api.github.com/users/mweinelt/orgs","repos_url":"https://api.github.com/users/mweinelt/repos","events_url":"https://api.github.com/users/mweinelt/events{/privacy}","received_events_url":"https://api.github.com/users/mweinelt/received_events","type":"User","site_admin":false},"body":"maybe put the closing bracket `)` into the newline, to increase readability.","created_at":"2016-06-22T14:19:51Z","updated_at":"2016-06-22T14:19:51Z","html_url":"https://github.com/matrix-org/Matrix-NEB/pull/14#discussion_r68061322","pull_request_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/14","_links":{"self":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/comments/68061322"},"html":{"href":"https://github.com/matrix-org/Matrix-NEB/pull/14#discussion_r68061322"},"pull_request":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/14"}}},"pull_request":{"url":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/14","id":74787351,"html_url":"https://github.com/matrix-org/Matrix-NEB/pull/14","diff_url":"https://github.com/matrix-org/Matrix-NEB/pull/14.diff","patch_url":"https://github.com/matrix-org/Matrix-NEB/pull/14.patch","issue_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/issues/14","number":14,"state":"open","locked":false,"title":"Alertmanager 0.1 and restricting to tracked projects","user":{"login":"superdump","id":302146,"avatar_url":"https://avatars.githubusercontent.com/u/302146?v=3","gravatar_id":"","url":"https://api.github.com/users/superdump","html_url":"https://github.com/superdump","followers_url":"https://api.github.com/users/superdump/followers","following_url":"https://api.github.com/users/superdump/following{/other_user}","gists_url":"https://api.github.com/users/superdump/gists{/gist_id}","starred_url":"https://api.github.com/users/superdump/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdump/subscriptions","organizations_url":"https://api.github.com/users/superdump/orgs","repos_url":"https://api.github.com/users/superdump/repos","events_url":"https://api.github.com/users/superdump/events{/privacy}","received_events_url":"https://api.github.com/users/superdump/received_events","type":"User","site_admin":false},"body":"This is all a bit of a hack.\r\n\r\nBasically to 'enable' alerts from prometheus to be sent to a room, I just `!prometheus track prometheus` in that room. prometheus is set as a known_project in the config file so that then when issuing that command, the room state is changed for tracking.\r\n\r\nThen, when the NEB instance is hit on the prometheus endpoint, it checks the room's state to see if the prometheus plugin state member for the room contains anything (it doesn't do actual project matching as I'm not plucking anything from the prometheus alertmanager payload to identify it yet) and if so then it will send the message to that room, else not.","created_at":"2016-06-22T13:50:36Z","updated_at":"2016-06-22T14:19:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"115d6e497e48506ee33550dfe923dc0d9976c8b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/14/commits","review_comments_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/14/comments","review_comment_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/issues/14/comments","statuses_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/statuses/69bcdc192572d824ca7f9b1f2231cecaeb9e71b0","head":{"label":"superdump:alertmanager-0.1","ref":"alertmanager-0.1","sha":"69bcdc192572d824ca7f9b1f2231cecaeb9e71b0","user":{"login":"superdump","id":302146,"avatar_url":"https://avatars.githubusercontent.com/u/302146?v=3","gravatar_id":"","url":"https://api.github.com/users/superdump","html_url":"https://github.com/superdump","followers_url":"https://api.github.com/users/superdump/followers","following_url":"https://api.github.com/users/superdump/following{/other_user}","gists_url":"https://api.github.com/users/superdump/gists{/gist_id}","starred_url":"https://api.github.com/users/superdump/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdump/subscriptions","organizations_url":"https://api.github.com/users/superdump/orgs","repos_url":"https://api.github.com/users/superdump/repos","events_url":"https://api.github.com/users/superdump/events{/privacy}","received_events_url":"https://api.github.com/users/superdump/received_events","type":"User","site_admin":false},"repo":{"id":61710057,"name":"Matrix-NEB","full_name":"superdump/Matrix-NEB","owner":{"login":"superdump","id":302146,"avatar_url":"https://avatars.githubusercontent.com/u/302146?v=3","gravatar_id":"","url":"https://api.github.com/users/superdump","html_url":"https://github.com/superdump","followers_url":"https://api.github.com/users/superdump/followers","following_url":"https://api.github.com/users/superdump/following{/other_user}","gists_url":"https://api.github.com/users/superdump/gists{/gist_id}","starred_url":"https://api.github.com/users/superdump/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/superdump/subscriptions","organizations_url":"https://api.github.com/users/superdump/orgs","repos_url":"https://api.github.com/users/superdump/repos","events_url":"https://api.github.com/users/superdump/events{/privacy}","received_events_url":"https://api.github.com/users/superdump/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/superdump/Matrix-NEB","description":"N E Bot: Generic bot for Matrix with plugin support","fork":true,"url":"https://api.github.com/repos/superdump/Matrix-NEB","forks_url":"https://api.github.com/repos/superdump/Matrix-NEB/forks","keys_url":"https://api.github.com/repos/superdump/Matrix-NEB/keys{/key_id}","collaborators_url":"https://api.github.com/repos/superdump/Matrix-NEB/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/superdump/Matrix-NEB/teams","hooks_url":"https://api.github.com/repos/superdump/Matrix-NEB/hooks","issue_events_url":"https://api.github.com/repos/superdump/Matrix-NEB/issues/events{/number}","events_url":"https://api.github.com/repos/superdump/Matrix-NEB/events","assignees_url":"https://api.github.com/repos/superdump/Matrix-NEB/assignees{/user}","branches_url":"https://api.github.com/repos/superdump/Matrix-NEB/branches{/branch}","tags_url":"https://api.github.com/repos/superdump/Matrix-NEB/tags","blobs_url":"https://api.github.com/repos/superdump/Matrix-NEB/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/superdump/Matrix-NEB/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/superdump/Matrix-NEB/git/refs{/sha}","trees_url":"https://api.github.com/repos/superdump/Matrix-NEB/git/trees{/sha}","statuses_url":"https://api.github.com/repos/superdump/Matrix-NEB/statuses/{sha}","languages_url":"https://api.github.com/repos/superdump/Matrix-NEB/languages","stargazers_url":"https://api.github.com/repos/superdump/Matrix-NEB/stargazers","contributors_url":"https://api.github.com/repos/superdump/Matrix-NEB/contributors","subscribers_url":"https://api.github.com/repos/superdump/Matrix-NEB/subscribers","subscription_url":"https://api.github.com/repos/superdump/Matrix-NEB/subscription","commits_url":"https://api.github.com/repos/superdump/Matrix-NEB/commits{/sha}","git_commits_url":"https://api.github.com/repos/superdump/Matrix-NEB/git/commits{/sha}","comments_url":"https://api.github.com/repos/superdump/Matrix-NEB/comments{/number}","issue_comment_url":"https://api.github.com/repos/superdump/Matrix-NEB/issues/comments{/number}","contents_url":"https://api.github.com/repos/superdump/Matrix-NEB/contents/{+path}","compare_url":"https://api.github.com/repos/superdump/Matrix-NEB/compare/{base}...{head}","merges_url":"https://api.github.com/repos/superdump/Matrix-NEB/merges","archive_url":"https://api.github.com/repos/superdump/Matrix-NEB/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/superdump/Matrix-NEB/downloads","issues_url":"https://api.github.com/repos/superdump/Matrix-NEB/issues{/number}","pulls_url":"https://api.github.com/repos/superdump/Matrix-NEB/pulls{/number}","milestones_url":"https://api.github.com/repos/superdump/Matrix-NEB/milestones{/number}","notifications_url":"https://api.github.com/repos/superdump/Matrix-NEB/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/superdump/Matrix-NEB/labels{/name}","releases_url":"https://api.github.com/repos/superdump/Matrix-NEB/releases{/id}","deployments_url":"https://api.github.com/repos/superdump/Matrix-NEB/deployments","created_at":"2016-06-22T10:22:45Z","updated_at":"2016-06-22T10:22:46Z","pushed_at":"2016-06-22T13:20:37Z","git_url":"git://github.com/superdump/Matrix-NEB.git","ssh_url":"git@github.com:superdump/Matrix-NEB.git","clone_url":"https://github.com/superdump/Matrix-NEB.git","svn_url":"https://github.com/superdump/Matrix-NEB","homepage":null,"size":148,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"matrix-org:master","ref":"master","sha":"7746023b62c90e9390112728690f9774aaf9642b","user":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"repo":{"id":23854125,"name":"Matrix-NEB","full_name":"matrix-org/Matrix-NEB","owner":{"login":"matrix-org","id":8418310,"avatar_url":"https://avatars.githubusercontent.com/u/8418310?v=3","gravatar_id":"","url":"https://api.github.com/users/matrix-org","html_url":"https://github.com/matrix-org","followers_url":"https://api.github.com/users/matrix-org/followers","following_url":"https://api.github.com/users/matrix-org/following{/other_user}","gists_url":"https://api.github.com/users/matrix-org/gists{/gist_id}","starred_url":"https://api.github.com/users/matrix-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matrix-org/subscriptions","organizations_url":"https://api.github.com/users/matrix-org/orgs","repos_url":"https://api.github.com/users/matrix-org/repos","events_url":"https://api.github.com/users/matrix-org/events{/privacy}","received_events_url":"https://api.github.com/users/matrix-org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matrix-org/Matrix-NEB","description":"N E Bot: Generic bot for Matrix with plugin support","fork":false,"url":"https://api.github.com/repos/matrix-org/Matrix-NEB","forks_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/forks","keys_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/teams","hooks_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/hooks","issue_events_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/issues/events{/number}","events_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/events","assignees_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/assignees{/user}","branches_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/branches{/branch}","tags_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/tags","blobs_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/git/refs{/sha}","trees_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/statuses/{sha}","languages_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/languages","stargazers_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/stargazers","contributors_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/contributors","subscribers_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/subscribers","subscription_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/subscription","commits_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/commits{/sha}","git_commits_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/git/commits{/sha}","comments_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/comments{/number}","issue_comment_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/issues/comments{/number}","contents_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/contents/{+path}","compare_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/merges","archive_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/downloads","issues_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/issues{/number}","pulls_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls{/number}","milestones_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/milestones{/number}","notifications_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/labels{/name}","releases_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/releases{/id}","deployments_url":"https://api.github.com/repos/matrix-org/Matrix-NEB/deployments","created_at":"2014-09-09T23:48:30Z","updated_at":"2016-05-29T21:14:32Z","pushed_at":"2016-06-22T13:50:36Z","git_url":"git://github.com/matrix-org/Matrix-NEB.git","ssh_url":"git@github.com:matrix-org/Matrix-NEB.git","clone_url":"https://github.com/matrix-org/Matrix-NEB.git","svn_url":"https://github.com/matrix-org/Matrix-NEB","homepage":null,"size":147,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/14"},"html":{"href":"https://github.com/matrix-org/Matrix-NEB/pull/14"},"issue":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/issues/14"},"comments":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/issues/14/comments"},"review_comments":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/14/comments"},"review_comment":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/pulls/14/commits"},"statuses":{"href":"https://api.github.com/repos/matrix-org/Matrix-NEB/statuses/69bcdc192572d824ca7f9b1f2231cecaeb9e71b0"}}}}
{"actor":{"display_login":"mweinelt"}}