{"action":"created","comment":{"url":"https://api.github.com/repos/Yelp/elastalert/pulls/comments/67086889","id":67086889,"diff_hunk":"@@ -555,33 +556,53 @@ def get_all_terms(self, args):\n                         level['values']['aggs'] = {'values': {'terms': copy.deepcopy(field_name)}}\n                         level = level['values']['aggs']\n             else:\n+                self.seen_values.setdefault(field, [])\n                 # For non-composite keys, only a single agg is needed\n                 field_name['field'] = add_raw_postfix(field)\n-            res = self.es.search(body=query, index=index, ignore_unavailable=True, timeout='50s')\n-            if 'aggregations' in res:\n-                buckets = res['aggregations']['filtered']['values']['buckets']\n-                if type(field) == list:\n-                    # For composite keys, make the lookup based on all fields\n-                    # Make it a tuple since it can be hashed and used in dictionary lookups\n-                    self.seen_values[tuple(field)] = []\n-                    for bucket in buckets:\n-                        # We need to walk down the hierarchy and obtain the value at each level\n-                        self.seen_values[tuple(field)] += self.flatten_aggregation_hierarchy(bucket)\n-                    # If we don't have any results, it could either be because of the absence of any baseline data\n-                    # OR it may be because the composite key contained a non-primitive type.  Either way, give the\n-                    # end-users a heads up to help them debug what might be going on.\n-                    if not self.seen_values[tuple(field)]:\n+\n+            # Query the entire time range in small chunks\n+            while tmp_start < end:\n+                if self.rules.get('use_strftime_index'):\n+                    index = format_index(self.rules['index'], tmp_start, tmp_end)\n+                else:\n+                    index = self.rules['index']\n+                res = self.es.search(body=query, index=index, ignore_unavailable=True, timeout='50s')\n+                if 'aggregations' in res:\n+                    buckets = res['aggregations']['filtered']['values']['buckets']\n+                    if type(field) == list:","path":"elastalert/ruletypes.py","position":86,"original_position":86,"commit_id":"5bf355f26705db2d0a5a44a393d3ed85c9d4f174","original_commit_id":"5bf355f26705db2d0a5a44a393d3ed85c9d4f174","user":{"login":"y-trobinso","id":2644744,"avatar_url":"https://avatars.githubusercontent.com/u/2644744?v=3","gravatar_id":"","url":"https://api.github.com/users/y-trobinso","html_url":"https://github.com/y-trobinso","followers_url":"https://api.github.com/users/y-trobinso/followers","following_url":"https://api.github.com/users/y-trobinso/following{/other_user}","gists_url":"https://api.github.com/users/y-trobinso/gists{/gist_id}","starred_url":"https://api.github.com/users/y-trobinso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/y-trobinso/subscriptions","organizations_url":"https://api.github.com/users/y-trobinso/orgs","repos_url":"https://api.github.com/users/y-trobinso/repos","events_url":"https://api.github.com/users/y-trobinso/events{/privacy}","received_events_url":"https://api.github.com/users/y-trobinso/received_events","type":"User","site_admin":false},"body":"Note that there are other collections than type(..) == list, and that this will not support subclassing whatsoever. Consider isinstance(..) or issubclass(..), and checking for __iter__ and other dunder methods you intend to use, if you care about that.","created_at":"2016-06-15T01:32:09Z","updated_at":"2016-06-15T01:32:09Z","html_url":"https://github.com/Yelp/elastalert/pull/578#discussion_r67086889","pull_request_url":"https://api.github.com/repos/Yelp/elastalert/pulls/578","_links":{"self":{"href":"https://api.github.com/repos/Yelp/elastalert/pulls/comments/67086889"},"html":{"href":"https://github.com/Yelp/elastalert/pull/578#discussion_r67086889"},"pull_request":{"href":"https://api.github.com/repos/Yelp/elastalert/pulls/578"}}},"pull_request":{"url":"https://api.github.com/repos/Yelp/elastalert/pulls/578","id":73838080,"html_url":"https://github.com/Yelp/elastalert/pull/578","diff_url":"https://github.com/Yelp/elastalert/pull/578.diff","patch_url":"https://github.com/Yelp/elastalert/pull/578.patch","issue_url":"https://api.github.com/repos/Yelp/elastalert/issues/578","number":578,"state":"open","locked":false,"title":"Split new_term queries into steps to avoid crazy timeouts","user":{"login":"Qmando","id":3246990,"avatar_url":"https://avatars.githubusercontent.com/u/3246990?v=3","gravatar_id":"","url":"https://api.github.com/users/Qmando","html_url":"https://github.com/Qmando","followers_url":"https://api.github.com/users/Qmando/followers","following_url":"https://api.github.com/users/Qmando/following{/other_user}","gists_url":"https://api.github.com/users/Qmando/gists{/gist_id}","starred_url":"https://api.github.com/users/Qmando/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qmando/subscriptions","organizations_url":"https://api.github.com/users/Qmando/orgs","repos_url":"https://api.github.com/users/Qmando/repos","events_url":"https://api.github.com/users/Qmando/events{/privacy}","received_events_url":"https://api.github.com/users/Qmando/received_events","type":"User","site_admin":false},"body":"When calling get_all_terms when a new_term rule starts, split the query (which is default 30 days) into (default 1 day) chunks. This can avoid timeouts because this can be a very expensive query to run. The step size is controllable via ``window_step_size``.","created_at":"2016-06-15T01:04:19Z","updated_at":"2016-06-15T01:32:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6affc57eed4797f021a93aec162d94d44b223eb8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Yelp/elastalert/pulls/578/commits","review_comments_url":"https://api.github.com/repos/Yelp/elastalert/pulls/578/comments","review_comment_url":"https://api.github.com/repos/Yelp/elastalert/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Yelp/elastalert/issues/578/comments","statuses_url":"https://api.github.com/repos/Yelp/elastalert/statuses/5bf355f26705db2d0a5a44a393d3ed85c9d4f174","head":{"label":"Yelp:step_new_term","ref":"step_new_term","sha":"5bf355f26705db2d0a5a44a393d3ed85c9d4f174","user":{"login":"Yelp","id":49071,"avatar_url":"https://avatars.githubusercontent.com/u/49071?v=3","gravatar_id":"","url":"https://api.github.com/users/Yelp","html_url":"https://github.com/Yelp","followers_url":"https://api.github.com/users/Yelp/followers","following_url":"https://api.github.com/users/Yelp/following{/other_user}","gists_url":"https://api.github.com/users/Yelp/gists{/gist_id}","starred_url":"https://api.github.com/users/Yelp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yelp/subscriptions","organizations_url":"https://api.github.com/users/Yelp/orgs","repos_url":"https://api.github.com/users/Yelp/repos","events_url":"https://api.github.com/users/Yelp/events{/privacy}","received_events_url":"https://api.github.com/users/Yelp/received_events","type":"Organization","site_admin":false},"repo":{"id":27091760,"name":"elastalert","full_name":"Yelp/elastalert","owner":{"login":"Yelp","id":49071,"avatar_url":"https://avatars.githubusercontent.com/u/49071?v=3","gravatar_id":"","url":"https://api.github.com/users/Yelp","html_url":"https://github.com/Yelp","followers_url":"https://api.github.com/users/Yelp/followers","following_url":"https://api.github.com/users/Yelp/following{/other_user}","gists_url":"https://api.github.com/users/Yelp/gists{/gist_id}","starred_url":"https://api.github.com/users/Yelp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yelp/subscriptions","organizations_url":"https://api.github.com/users/Yelp/orgs","repos_url":"https://api.github.com/users/Yelp/repos","events_url":"https://api.github.com/users/Yelp/events{/privacy}","received_events_url":"https://api.github.com/users/Yelp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Yelp/elastalert","description":"Easy & Flexible Alerting With ElasticSearch","fork":false,"url":"https://api.github.com/repos/Yelp/elastalert","forks_url":"https://api.github.com/repos/Yelp/elastalert/forks","keys_url":"https://api.github.com/repos/Yelp/elastalert/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yelp/elastalert/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yelp/elastalert/teams","hooks_url":"https://api.github.com/repos/Yelp/elastalert/hooks","issue_events_url":"https://api.github.com/repos/Yelp/elastalert/issues/events{/number}","events_url":"https://api.github.com/repos/Yelp/elastalert/events","assignees_url":"https://api.github.com/repos/Yelp/elastalert/assignees{/user}","branches_url":"https://api.github.com/repos/Yelp/elastalert/branches{/branch}","tags_url":"https://api.github.com/repos/Yelp/elastalert/tags","blobs_url":"https://api.github.com/repos/Yelp/elastalert/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yelp/elastalert/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yelp/elastalert/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yelp/elastalert/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yelp/elastalert/statuses/{sha}","languages_url":"https://api.github.com/repos/Yelp/elastalert/languages","stargazers_url":"https://api.github.com/repos/Yelp/elastalert/stargazers","contributors_url":"https://api.github.com/repos/Yelp/elastalert/contributors","subscribers_url":"https://api.github.com/repos/Yelp/elastalert/subscribers","subscription_url":"https://api.github.com/repos/Yelp/elastalert/subscription","commits_url":"https://api.github.com/repos/Yelp/elastalert/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yelp/elastalert/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yelp/elastalert/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yelp/elastalert/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yelp/elastalert/contents/{+path}","compare_url":"https://api.github.com/repos/Yelp/elastalert/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yelp/elastalert/merges","archive_url":"https://api.github.com/repos/Yelp/elastalert/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yelp/elastalert/downloads","issues_url":"https://api.github.com/repos/Yelp/elastalert/issues{/number}","pulls_url":"https://api.github.com/repos/Yelp/elastalert/pulls{/number}","milestones_url":"https://api.github.com/repos/Yelp/elastalert/milestones{/number}","notifications_url":"https://api.github.com/repos/Yelp/elastalert/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yelp/elastalert/labels{/name}","releases_url":"https://api.github.com/repos/Yelp/elastalert/releases{/id}","deployments_url":"https://api.github.com/repos/Yelp/elastalert/deployments","created_at":"2014-11-24T19:39:19Z","updated_at":"2016-06-14T17:30:39Z","pushed_at":"2016-06-15T01:04:19Z","git_url":"git://github.com/Yelp/elastalert.git","ssh_url":"git@github.com:Yelp/elastalert.git","clone_url":"https://github.com/Yelp/elastalert.git","svn_url":"https://github.com/Yelp/elastalert","homepage":"https://elastalert.readthedocs.org","size":1538,"stargazers_count":1977,"watchers_count":1977,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":273,"mirror_url":null,"open_issues_count":148,"forks":273,"open_issues":148,"watchers":1977,"default_branch":"master"}},"base":{"label":"Yelp:master","ref":"master","sha":"384c6d2568e70c9ac3e557725132c0005791ce74","user":{"login":"Yelp","id":49071,"avatar_url":"https://avatars.githubusercontent.com/u/49071?v=3","gravatar_id":"","url":"https://api.github.com/users/Yelp","html_url":"https://github.com/Yelp","followers_url":"https://api.github.com/users/Yelp/followers","following_url":"https://api.github.com/users/Yelp/following{/other_user}","gists_url":"https://api.github.com/users/Yelp/gists{/gist_id}","starred_url":"https://api.github.com/users/Yelp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yelp/subscriptions","organizations_url":"https://api.github.com/users/Yelp/orgs","repos_url":"https://api.github.com/users/Yelp/repos","events_url":"https://api.github.com/users/Yelp/events{/privacy}","received_events_url":"https://api.github.com/users/Yelp/received_events","type":"Organization","site_admin":false},"repo":{"id":27091760,"name":"elastalert","full_name":"Yelp/elastalert","owner":{"login":"Yelp","id":49071,"avatar_url":"https://avatars.githubusercontent.com/u/49071?v=3","gravatar_id":"","url":"https://api.github.com/users/Yelp","html_url":"https://github.com/Yelp","followers_url":"https://api.github.com/users/Yelp/followers","following_url":"https://api.github.com/users/Yelp/following{/other_user}","gists_url":"https://api.github.com/users/Yelp/gists{/gist_id}","starred_url":"https://api.github.com/users/Yelp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yelp/subscriptions","organizations_url":"https://api.github.com/users/Yelp/orgs","repos_url":"https://api.github.com/users/Yelp/repos","events_url":"https://api.github.com/users/Yelp/events{/privacy}","received_events_url":"https://api.github.com/users/Yelp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Yelp/elastalert","description":"Easy & Flexible Alerting With ElasticSearch","fork":false,"url":"https://api.github.com/repos/Yelp/elastalert","forks_url":"https://api.github.com/repos/Yelp/elastalert/forks","keys_url":"https://api.github.com/repos/Yelp/elastalert/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yelp/elastalert/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yelp/elastalert/teams","hooks_url":"https://api.github.com/repos/Yelp/elastalert/hooks","issue_events_url":"https://api.github.com/repos/Yelp/elastalert/issues/events{/number}","events_url":"https://api.github.com/repos/Yelp/elastalert/events","assignees_url":"https://api.github.com/repos/Yelp/elastalert/assignees{/user}","branches_url":"https://api.github.com/repos/Yelp/elastalert/branches{/branch}","tags_url":"https://api.github.com/repos/Yelp/elastalert/tags","blobs_url":"https://api.github.com/repos/Yelp/elastalert/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yelp/elastalert/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yelp/elastalert/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yelp/elastalert/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yelp/elastalert/statuses/{sha}","languages_url":"https://api.github.com/repos/Yelp/elastalert/languages","stargazers_url":"https://api.github.com/repos/Yelp/elastalert/stargazers","contributors_url":"https://api.github.com/repos/Yelp/elastalert/contributors","subscribers_url":"https://api.github.com/repos/Yelp/elastalert/subscribers","subscription_url":"https://api.github.com/repos/Yelp/elastalert/subscription","commits_url":"https://api.github.com/repos/Yelp/elastalert/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yelp/elastalert/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yelp/elastalert/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yelp/elastalert/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yelp/elastalert/contents/{+path}","compare_url":"https://api.github.com/repos/Yelp/elastalert/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yelp/elastalert/merges","archive_url":"https://api.github.com/repos/Yelp/elastalert/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yelp/elastalert/downloads","issues_url":"https://api.github.com/repos/Yelp/elastalert/issues{/number}","pulls_url":"https://api.github.com/repos/Yelp/elastalert/pulls{/number}","milestones_url":"https://api.github.com/repos/Yelp/elastalert/milestones{/number}","notifications_url":"https://api.github.com/repos/Yelp/elastalert/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yelp/elastalert/labels{/name}","releases_url":"https://api.github.com/repos/Yelp/elastalert/releases{/id}","deployments_url":"https://api.github.com/repos/Yelp/elastalert/deployments","created_at":"2014-11-24T19:39:19Z","updated_at":"2016-06-14T17:30:39Z","pushed_at":"2016-06-15T01:04:19Z","git_url":"git://github.com/Yelp/elastalert.git","ssh_url":"git@github.com:Yelp/elastalert.git","clone_url":"https://github.com/Yelp/elastalert.git","svn_url":"https://github.com/Yelp/elastalert","homepage":"https://elastalert.readthedocs.org","size":1538,"stargazers_count":1977,"watchers_count":1977,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":273,"mirror_url":null,"open_issues_count":148,"forks":273,"open_issues":148,"watchers":1977,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Yelp/elastalert/pulls/578"},"html":{"href":"https://github.com/Yelp/elastalert/pull/578"},"issue":{"href":"https://api.github.com/repos/Yelp/elastalert/issues/578"},"comments":{"href":"https://api.github.com/repos/Yelp/elastalert/issues/578/comments"},"review_comments":{"href":"https://api.github.com/repos/Yelp/elastalert/pulls/578/comments"},"review_comment":{"href":"https://api.github.com/repos/Yelp/elastalert/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Yelp/elastalert/pulls/578/commits"},"statuses":{"href":"https://api.github.com/repos/Yelp/elastalert/statuses/5bf355f26705db2d0a5a44a393d3ed85c9d4f174"}}}}
{"actor":{"display_login":"y-trobinso"}}