{"action":"created","comment":{"url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/comments/24778039","id":24778039,"diff_hunk":"@@ -14,7 +15,8 @@ import (\n // Poll dispatches notification checks when needed.\n func (s *Schedule) Poll() {\n \tfor {\n-\t\trh := s.NewRunHistory(time.Now())\n+\t\tcache := cache.New()\n+\t\trh := s.NewRunHistory(time.Now(), *cache)","path":"cmd/bosun/sched/notify.go","position":14,"original_position":14,"commit_id":"8104907a34d308d6dd0ed014ef0bb2444f68a4a7","original_commit_id":"8104907a34d308d6dd0ed014ef0bb2444f68a4a7","user":{"login":"mjibson","id":41181,"avatar_url":"https://avatars.githubusercontent.com/u/41181?v=3","gravatar_id":"","url":"https://api.github.com/users/mjibson","html_url":"https://github.com/mjibson","followers_url":"https://api.github.com/users/mjibson/followers","following_url":"https://api.github.com/users/mjibson/following{/other_user}","gists_url":"https://api.github.com/users/mjibson/gists{/gist_id}","starred_url":"https://api.github.com/users/mjibson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjibson/subscriptions","organizations_url":"https://api.github.com/users/mjibson/orgs","repos_url":"https://api.github.com/users/mjibson/repos","events_url":"https://api.github.com/users/mjibson/events{/privacy}","received_events_url":"https://api.github.com/users/mjibson/received_events","type":"User","site_admin":false},"body":"merge","created_at":"2015-02-16T21:47:06Z","updated_at":"2015-02-16T21:47:06Z","html_url":"https://github.com/bosun-monitor/bosun/pull/715#discussion_r24778039","pull_request_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/715","_links":{"self":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/comments/24778039"},"html":{"href":"https://github.com/bosun-monitor/bosun/pull/715#discussion_r24778039"},"pull_request":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/715"}}},"pull_request":{"url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/715","id":29217535,"html_url":"https://github.com/bosun-monitor/bosun/pull/715","diff_url":"https://github.com/bosun-monitor/bosun/pull/715.diff","patch_url":"https://github.com/bosun-monitor/bosun/pull/715.patch","issue_url":"https://api.github.com/repos/bosun-monitor/bosun/issues/715","number":715,"state":"open","locked":false,"title":"leverage LRU caching for scheduled checks and expr/rule tests","user":{"login":"Dieterbe","id":20774,"avatar_url":"https://avatars.githubusercontent.com/u/20774?v=3","gravatar_id":"","url":"https://api.github.com/users/Dieterbe","html_url":"https://github.com/Dieterbe","followers_url":"https://api.github.com/users/Dieterbe/followers","following_url":"https://api.github.com/users/Dieterbe/following{/other_user}","gists_url":"https://api.github.com/users/Dieterbe/gists{/gist_id}","starred_url":"https://api.github.com/users/Dieterbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dieterbe/subscriptions","organizations_url":"https://api.github.com/users/Dieterbe/orgs","repos_url":"https://api.github.com/users/Dieterbe/repos","events_url":"https://api.github.com/users/Dieterbe/events{/privacy}","received_events_url":"https://api.github.com/users/Dieterbe/received_events","type":"User","site_admin":false},"body":"* for executing expressions/rules via the web UI, we use\r\na cache that we retain during the lifetime of bosun\r\nMatt and I decided not to expire the cache at given points (such as\r\nreloading rule page), but I forgot why. ?\r\nthe only risk is that if you query your store for data -5m to now\r\nand your store doesn't have the latest points up to date,\r\nand then 5m from now you query -10min to -5m you'll get the same\r\ncached data, including the incomplete last points\r\n\r\n* for scheduled alert checking, the cache lifetime is only each\r\nspecific run so that different queries of the same\r\ndata for different templates are optimized and values reused in\r\ntemplates are guaranteed to be in sync.\r\nwe don't make the lifetime longer to prevent affecting\r\nfuture queries (perhaps a band() a week\r\nfrom now which queries now-current data we just queried and might be\r\nincomplete)\r\nalso there's likely less benefit (low hit rate) in keeping the cache\r\nacross alerting runs\r\n\r\nnote that Schedule.Check(), Schedule.Poll() and\r\nSchedule.CheckUnknown() currently use their own caches for each run.\r\nSchedule.Poll() runs on its own schedule and Schedule.CheckUnknown()\r\nruns every checkinterval/4..\r\nWe should probably reuse the caching more across these checking\r\nfunctions.  But I leave this up to Matt who knows more about this.\r\n\r\nNote:\r\n* graphite is tested, opentsdb is not.\r\n* i did not work on logstash\r\n","created_at":"2015-02-12T21:24:47Z","updated_at":"2015-02-16T21:47:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8ab3a9393b0ea114aa8556b5593e2ba3a59014f1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/715/commits","review_comments_url":"https://api.github.com/repos/bosun-monitor/bosun/pulls/715/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/715/comments","statuses_url":"https://api.github.com/repos/bosun-monitor/bosun/statuses/8104907a34d308d6dd0ed014ef0bb2444f68a4a7","head":{"label":"vimeo:cache","ref":"cache","sha":"8104907a34d308d6dd0ed014ef0bb2444f68a4a7","user":{"login":"vimeo","id":317769,"avatar_url":"https://avatars.githubusercontent.com/u/317769?v=3","gravatar_id":"","url":"https://api.github.com/users/vimeo","html_url":"https://github.com/vimeo","followers_url":"https://api.github.com/users/vimeo/followers","following_url":"https://api.github.com/users/vimeo/following{/other_user}","gists_url":"https://api.github.com/users/vimeo/gists{/gist_id}","starred_url":"https://api.github.com/users/vimeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vimeo/subscriptions","organizations_url":"https://api.github.com/users/vimeo/orgs","repos_url":"https://api.github.com/users/vimeo/repos","events_url":"https://api.github.com/users/vimeo/events{/privacy}","received_events_url":"https://api.github.com/users/vimeo/received_events","type":"Organization","site_admin":false},"repo":{"id":28147479,"name":"bosun","full_name":"vimeo/bosun","owner":{"login":"vimeo","id":317769,"avatar_url":"https://avatars.githubusercontent.com/u/317769?v=3","gravatar_id":"","url":"https://api.github.com/users/vimeo","html_url":"https://github.com/vimeo","followers_url":"https://api.github.com/users/vimeo/followers","following_url":"https://api.github.com/users/vimeo/following{/other_user}","gists_url":"https://api.github.com/users/vimeo/gists{/gist_id}","starred_url":"https://api.github.com/users/vimeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vimeo/subscriptions","organizations_url":"https://api.github.com/users/vimeo/orgs","repos_url":"https://api.github.com/users/vimeo/repos","events_url":"https://api.github.com/users/vimeo/events{/privacy}","received_events_url":"https://api.github.com/users/vimeo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vimeo/bosun","description":"Time Series Alerting Framework","fork":true,"url":"https://api.github.com/repos/vimeo/bosun","forks_url":"https://api.github.com/repos/vimeo/bosun/forks","keys_url":"https://api.github.com/repos/vimeo/bosun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vimeo/bosun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vimeo/bosun/teams","hooks_url":"https://api.github.com/repos/vimeo/bosun/hooks","issue_events_url":"https://api.github.com/repos/vimeo/bosun/issues/events{/number}","events_url":"https://api.github.com/repos/vimeo/bosun/events","assignees_url":"https://api.github.com/repos/vimeo/bosun/assignees{/user}","branches_url":"https://api.github.com/repos/vimeo/bosun/branches{/branch}","tags_url":"https://api.github.com/repos/vimeo/bosun/tags","blobs_url":"https://api.github.com/repos/vimeo/bosun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vimeo/bosun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vimeo/bosun/git/refs{/sha}","trees_url":"https://api.github.com/repos/vimeo/bosun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vimeo/bosun/statuses/{sha}","languages_url":"https://api.github.com/repos/vimeo/bosun/languages","stargazers_url":"https://api.github.com/repos/vimeo/bosun/stargazers","contributors_url":"https://api.github.com/repos/vimeo/bosun/contributors","subscribers_url":"https://api.github.com/repos/vimeo/bosun/subscribers","subscription_url":"https://api.github.com/repos/vimeo/bosun/subscription","commits_url":"https://api.github.com/repos/vimeo/bosun/commits{/sha}","git_commits_url":"https://api.github.com/repos/vimeo/bosun/git/commits{/sha}","comments_url":"https://api.github.com/repos/vimeo/bosun/comments{/number}","issue_comment_url":"https://api.github.com/repos/vimeo/bosun/issues/comments/{number}","contents_url":"https://api.github.com/repos/vimeo/bosun/contents/{+path}","compare_url":"https://api.github.com/repos/vimeo/bosun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vimeo/bosun/merges","archive_url":"https://api.github.com/repos/vimeo/bosun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vimeo/bosun/downloads","issues_url":"https://api.github.com/repos/vimeo/bosun/issues{/number}","pulls_url":"https://api.github.com/repos/vimeo/bosun/pulls{/number}","milestones_url":"https://api.github.com/repos/vimeo/bosun/milestones{/number}","notifications_url":"https://api.github.com/repos/vimeo/bosun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vimeo/bosun/labels{/name}","releases_url":"https://api.github.com/repos/vimeo/bosun/releases{/id}","created_at":"2014-12-17T17:23:43Z","updated_at":"2015-01-11T11:33:56Z","pushed_at":"2015-02-16T21:15:38Z","git_url":"git://github.com/vimeo/bosun.git","ssh_url":"git@github.com:vimeo/bosun.git","clone_url":"https://github.com/vimeo/bosun.git","svn_url":"https://github.com/vimeo/bosun","homepage":"http://bosun.org","size":11276,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"base":{"label":"bosun-monitor:master","ref":"master","sha":"d34c6945842d1b48364f5838e5a5d11097b2970c","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}","created_at":"2013-11-15T00:12:27Z","updated_at":"2015-02-16T20:52:51Z","pushed_at":"2015-02-15T19:42:20Z","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":25867,"stargazers_count":703,"watchers_count":703,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":160,"forks":63,"open_issues":160,"watchers":703,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/715"},"html":{"href":"https://github.com/bosun-monitor/bosun/pull/715"},"issue":{"href":"https://api.github.com/repos/bosun-monitor/bosun/issues/715"},"comments":{"href":"https://api.github.com/repos/bosun-monitor/bosun/issues/715/comments"},"review_comments":{"href":"https://api.github.com/repos/bosun-monitor/bosun/pulls/715/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/715/commits"},"statuses":{"href":"https://api.github.com/repos/bosun-monitor/bosun/statuses/8104907a34d308d6dd0ed014ef0bb2444f68a4a7"}}}}