{"action":"created","comment":{"url":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/comments/193115260","pull_request_review_id":126023082,"id":193115260,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzExNTI2MA==","diff_hunk":"@@ -0,0 +1,79 @@\n+# Copyright 2015-2017 Capital One Services, LLC\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+from datetime import timedelta\n+from c7n_azure.metrics import Metrics\n+from c7n.filters import Filter\n+\n+\n+def mean(numbers):\n+    if numbers is None:\n+        return None\n+    total = 0.0\n+    count = 0.0\n+    for n in numbers:\n+        if n is not None:\n+            total += n\n+            count += 1\n+    if count == 0:\n+        return None\n+    return total / count\n+\n+\n+class MetricFilter(Filter):\n+\n+    funcs = {\n+        'max': max,\n+        'min': min,\n+        'avg': mean\n+    }\n+\n+    def validate(self):\n+        self.metric = self.data.get('metric')\n+        self.func = self.funcs[self.data.get('func', 'avg')]\n+        self.op = self.data.get('op')\n+        self.threshold = self.data.get('threshold')\n+        if self.metric is None:\n+            raise ValueError(\"Need to define a metric\")\n+        if self.func is None:\n+            raise ValueError(\"Need to define a func (avg, min, max)\")\n+        if self.op is None:\n+            raise ValueError(\"Need to define an opeartor (gt, ge, eq, le, lt)\")\n+        if self.threshold is None:\n+            raise ValueError(\"Need to define a threshold\")\n+        self.threshold = float(self.threshold)\n+        self.timeframe = float(self.data.get('timeframe', 24))\n+        self.client = self.manager.get_client('azure.mgmt.monitor.MonitorManagementClient')\n+\n+    def __call__(self, resource):\n+\n+        m = Metrics(self.client, resource['id'])\n+        from c7n_azure.actions import utcnow","path":"tools/c7n_azure/c7n_azure/filters.py","position":61,"original_position":61,"commit_id":"99648d53716c518c852587e2db7d86b4fe27ee79","original_commit_id":"99648d53716c518c852587e2db7d86b4fe27ee79","user":{"login":"tbarlow12","id":10962815,"node_id":"MDQ6VXNlcjEwOTYyODE1","avatar_url":"https://avatars0.githubusercontent.com/u/10962815?v=4","gravatar_id":"","url":"https://api.github.com/users/tbarlow12","html_url":"https://github.com/tbarlow12","followers_url":"https://api.github.com/users/tbarlow12/followers","following_url":"https://api.github.com/users/tbarlow12/following{/other_user}","gists_url":"https://api.github.com/users/tbarlow12/gists{/gist_id}","starred_url":"https://api.github.com/users/tbarlow12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbarlow12/subscriptions","organizations_url":"https://api.github.com/users/tbarlow12/orgs","repos_url":"https://api.github.com/users/tbarlow12/repos","events_url":"https://api.github.com/users/tbarlow12/events{/privacy}","received_events_url":"https://api.github.com/users/tbarlow12/received_events","type":"User","site_admin":false},"body":"yeah, I had it at the top of the file, but it wasn't getting the overridden function. `utcnow()` was still giving me the current datetime","created_at":"2018-06-05T15:22:47Z","updated_at":"2018-06-05T15:22:47Z","html_url":"https://github.com/tbarlow12/cloud-custodian/pull/1#discussion_r193115260","pull_request_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/1","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/comments/193115260"},"html":{"href":"https://github.com/tbarlow12/cloud-custodian/pull/1#discussion_r193115260"},"pull_request":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/1"}},"in_reply_to_id":193087050},"pull_request":{"url":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/1","id":191290878,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkxMjkwODc4","html_url":"https://github.com/tbarlow12/cloud-custodian/pull/1","diff_url":"https://github.com/tbarlow12/cloud-custodian/pull/1.diff","patch_url":"https://github.com/tbarlow12/cloud-custodian/pull/1.patch","issue_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues/1","number":1,"state":"open","locked":false,"title":"Azure metrics","user":{"login":"tbarlow12","id":10962815,"node_id":"MDQ6VXNlcjEwOTYyODE1","avatar_url":"https://avatars0.githubusercontent.com/u/10962815?v=4","gravatar_id":"","url":"https://api.github.com/users/tbarlow12","html_url":"https://github.com/tbarlow12","followers_url":"https://api.github.com/users/tbarlow12/followers","following_url":"https://api.github.com/users/tbarlow12/following{/other_user}","gists_url":"https://api.github.com/users/tbarlow12/gists{/gist_id}","starred_url":"https://api.github.com/users/tbarlow12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbarlow12/subscriptions","organizations_url":"https://api.github.com/users/tbarlow12/orgs","repos_url":"https://api.github.com/users/tbarlow12/repos","events_url":"https://api.github.com/users/tbarlow12/events{/privacy}","received_events_url":"https://api.github.com/users/tbarlow12/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-29T22:53:40Z","updated_at":"2018-06-05T15:22:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0c0f3e0dece987a56f56e4b0d40c38371978bd40","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/1/commits","review_comments_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/1/comments","review_comment_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues/1/comments","statuses_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/statuses/99648d53716c518c852587e2db7d86b4fe27ee79","head":{"label":"tbarlow12:azure-metrics","ref":"azure-metrics","sha":"99648d53716c518c852587e2db7d86b4fe27ee79","user":{"login":"tbarlow12","id":10962815,"node_id":"MDQ6VXNlcjEwOTYyODE1","avatar_url":"https://avatars0.githubusercontent.com/u/10962815?v=4","gravatar_id":"","url":"https://api.github.com/users/tbarlow12","html_url":"https://github.com/tbarlow12","followers_url":"https://api.github.com/users/tbarlow12/followers","following_url":"https://api.github.com/users/tbarlow12/following{/other_user}","gists_url":"https://api.github.com/users/tbarlow12/gists{/gist_id}","starred_url":"https://api.github.com/users/tbarlow12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbarlow12/subscriptions","organizations_url":"https://api.github.com/users/tbarlow12/orgs","repos_url":"https://api.github.com/users/tbarlow12/repos","events_url":"https://api.github.com/users/tbarlow12/events{/privacy}","received_events_url":"https://api.github.com/users/tbarlow12/received_events","type":"User","site_admin":false},"repo":{"id":132810137,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI4MTAxMzc=","name":"cloud-custodian","full_name":"tbarlow12/cloud-custodian","owner":{"login":"tbarlow12","id":10962815,"node_id":"MDQ6VXNlcjEwOTYyODE1","avatar_url":"https://avatars0.githubusercontent.com/u/10962815?v=4","gravatar_id":"","url":"https://api.github.com/users/tbarlow12","html_url":"https://github.com/tbarlow12","followers_url":"https://api.github.com/users/tbarlow12/followers","following_url":"https://api.github.com/users/tbarlow12/following{/other_user}","gists_url":"https://api.github.com/users/tbarlow12/gists{/gist_id}","starred_url":"https://api.github.com/users/tbarlow12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbarlow12/subscriptions","organizations_url":"https://api.github.com/users/tbarlow12/orgs","repos_url":"https://api.github.com/users/tbarlow12/repos","events_url":"https://api.github.com/users/tbarlow12/events{/privacy}","received_events_url":"https://api.github.com/users/tbarlow12/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tbarlow12/cloud-custodian","description":"Rules engine for cloud fleet management and governance, DSL in yaml for policies to query, filter, and take actions on resources","fork":true,"url":"https://api.github.com/repos/tbarlow12/cloud-custodian","forks_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/forks","keys_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/teams","hooks_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/hooks","issue_events_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues/events{/number}","events_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/events","assignees_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/assignees{/user}","branches_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/branches{/branch}","tags_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/tags","blobs_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/refs{/sha}","trees_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/statuses/{sha}","languages_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/languages","stargazers_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/stargazers","contributors_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/contributors","subscribers_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/subscribers","subscription_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/subscription","commits_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/commits{/sha}","git_commits_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/commits{/sha}","comments_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/comments{/number}","issue_comment_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues/comments{/number}","contents_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/contents/{+path}","compare_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/merges","archive_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/downloads","issues_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues{/number}","pulls_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls{/number}","milestones_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/milestones{/number}","notifications_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/labels{/name}","releases_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/releases{/id}","deployments_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/deployments","created_at":"2018-05-09T20:35:48Z","updated_at":"2018-05-29T22:58:54Z","pushed_at":"2018-06-05T13:29:26Z","git_url":"git://github.com/tbarlow12/cloud-custodian.git","ssh_url":"git@github.com:tbarlow12/cloud-custodian.git","clone_url":"https://github.com/tbarlow12/cloud-custodian.git","svn_url":"https://github.com/tbarlow12/cloud-custodian","homepage":"https://developer.capitalone.com/opensource-projects/cloud-custodian","size":59617,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"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":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"tbarlow12:master","ref":"master","sha":"380d1cf38fcba7ed5c6505d73916d60e51325af3","user":{"login":"tbarlow12","id":10962815,"node_id":"MDQ6VXNlcjEwOTYyODE1","avatar_url":"https://avatars0.githubusercontent.com/u/10962815?v=4","gravatar_id":"","url":"https://api.github.com/users/tbarlow12","html_url":"https://github.com/tbarlow12","followers_url":"https://api.github.com/users/tbarlow12/followers","following_url":"https://api.github.com/users/tbarlow12/following{/other_user}","gists_url":"https://api.github.com/users/tbarlow12/gists{/gist_id}","starred_url":"https://api.github.com/users/tbarlow12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbarlow12/subscriptions","organizations_url":"https://api.github.com/users/tbarlow12/orgs","repos_url":"https://api.github.com/users/tbarlow12/repos","events_url":"https://api.github.com/users/tbarlow12/events{/privacy}","received_events_url":"https://api.github.com/users/tbarlow12/received_events","type":"User","site_admin":false},"repo":{"id":132810137,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI4MTAxMzc=","name":"cloud-custodian","full_name":"tbarlow12/cloud-custodian","owner":{"login":"tbarlow12","id":10962815,"node_id":"MDQ6VXNlcjEwOTYyODE1","avatar_url":"https://avatars0.githubusercontent.com/u/10962815?v=4","gravatar_id":"","url":"https://api.github.com/users/tbarlow12","html_url":"https://github.com/tbarlow12","followers_url":"https://api.github.com/users/tbarlow12/followers","following_url":"https://api.github.com/users/tbarlow12/following{/other_user}","gists_url":"https://api.github.com/users/tbarlow12/gists{/gist_id}","starred_url":"https://api.github.com/users/tbarlow12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbarlow12/subscriptions","organizations_url":"https://api.github.com/users/tbarlow12/orgs","repos_url":"https://api.github.com/users/tbarlow12/repos","events_url":"https://api.github.com/users/tbarlow12/events{/privacy}","received_events_url":"https://api.github.com/users/tbarlow12/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tbarlow12/cloud-custodian","description":"Rules engine for cloud fleet management and governance, DSL in yaml for policies to query, filter, and take actions on resources","fork":true,"url":"https://api.github.com/repos/tbarlow12/cloud-custodian","forks_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/forks","keys_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/teams","hooks_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/hooks","issue_events_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues/events{/number}","events_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/events","assignees_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/assignees{/user}","branches_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/branches{/branch}","tags_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/tags","blobs_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/refs{/sha}","trees_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/statuses/{sha}","languages_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/languages","stargazers_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/stargazers","contributors_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/contributors","subscribers_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/subscribers","subscription_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/subscription","commits_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/commits{/sha}","git_commits_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/git/commits{/sha}","comments_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/comments{/number}","issue_comment_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues/comments{/number}","contents_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/contents/{+path}","compare_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/merges","archive_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/downloads","issues_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues{/number}","pulls_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls{/number}","milestones_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/milestones{/number}","notifications_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/labels{/name}","releases_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/releases{/id}","deployments_url":"https://api.github.com/repos/tbarlow12/cloud-custodian/deployments","created_at":"2018-05-09T20:35:48Z","updated_at":"2018-05-29T22:58:54Z","pushed_at":"2018-06-05T13:29:26Z","git_url":"git://github.com/tbarlow12/cloud-custodian.git","ssh_url":"git@github.com:tbarlow12/cloud-custodian.git","clone_url":"https://github.com/tbarlow12/cloud-custodian.git","svn_url":"https://github.com/tbarlow12/cloud-custodian","homepage":"https://developer.capitalone.com/opensource-projects/cloud-custodian","size":59617,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"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":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/1"},"html":{"href":"https://github.com/tbarlow12/cloud-custodian/pull/1"},"issue":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues/1"},"comments":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/tbarlow12/cloud-custodian/statuses/99648d53716c518c852587e2db7d86b4fe27ee79"}},"author_association":"OWNER"}}
{"actor":{"display_login":"tbarlow12"}}