{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/comments/34729302","id":34729302,"diff_hunk":"@@ -0,0 +1,298 @@\n+// Copyright 2015 Google Inc. All Rights Reserved.\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+\n+package v1\n+\n+import (\n+\t\"net/http\"\n+\t\"time\"\n+\n+\trestful \"github.com/emicklei/go-restful\"\n+\t\"github.com/golang/glog\"\n+\n+\t\"github.com/GoogleCloudPlatform/heapster/store\"\n+)\n+\n+// Register the Model API endpoints\n+func (a *Api) RegisterModel(container *restful.Container) {\n+\tws := new(restful.WebService)\n+\tws.\n+\t\tPath(\"/api/v1/model\").\n+\t\tDoc(\"Exports all aggregated Cluster-level metrics since the specified start time\").\n+\t\tConsumes(\"*/*\").\n+\t\tProduces(restful.MIME_JSON)\n+\n+\t// The /endpoint returns a list of all the metrics that are available in the model\n+\tws.Route(ws.GET(\"/\").\n+\t\tTo(a.availableMetrics).\n+\t\tFilter(compressionFilter).\n+\t\tDoc(\"Show which metrics are available\").\n+\t\tOperation(\"clusterMetrics\"))\n+\n+\t// The /cluster endpoint exposes aggregated metrics for the Cluster entity of the model.\n+\tws.Route(ws.GET(\"/cluster/{metric-name}\").\n+\t\tTo(a.clusterMetrics).\n+\t\tFilter(compressionFilter).\n+\t\tDoc(\"export all aggregated cluster-level metrics\").\n+\t\tOperation(\"clusterMetrics\").\n+\t\tParam(ws.PathParameter(\"metric-name\", \"The name of the requested metric\").DataType(\"string\")).\n+\t\tParam(ws.QueryParameter(\"start\", \"Start time for requested metrics\").DataType(\"string\")).\n+\t\tWrites(MetricResult{}))\n+\n+\t// The /node/ endpoint exposes metrics for the Node entity of the model.\n+\tws.Route(ws.GET(\"/node/{node-name}/{metric-name}\").\n+\t\tTo(a.nodeMetrics).\n+\t\tFilter(compressionFilter).\n+\t\tDoc(\"export all node-level metrics\").\n+\t\tOperation(\"nodeMetrics\").\n+\t\tParam(ws.PathParameter(\"node-name\", \"The name of the node to lookup\").DataType(\"string\")).\n+\t\tParam(ws.PathParameter(\"metric-name\", \"The name of the requested metric\").DataType(\"string\")).\n+\t\tParam(ws.QueryParameter(\"start\", \"Start time for requested metrics\").DataType(\"string\")).\n+\t\tWrites(MetricResult{}))\n+\n+\t// The /namespace/ endpoint exposes aggregated metrics for the Namespace entity of the model.\n+\tws.Route(ws.GET(\"/namespace/{namespace-name}/{metric-name}\").\n+\t\tTo(a.namespaceMetrics).\n+\t\tFilter(compressionFilter).\n+\t\tDoc(\"export all aggregated namespace-level metrics\").\n+\t\tOperation(\"namespaceMetrics\").\n+\t\tParam(ws.PathParameter(\"metric-name\", \"The name of the requested metric\").DataType(\"string\")).\n+\t\tParam(ws.QueryParameter(\"start\", \"Start time for requested metrics\").DataType(\"string\")).\n+\t\tWrites(MetricResult{}))\n+\n+\t// The /namespace/{}/pod endpoint exposes aggregated metrics for the Pod entity of the model.\n+\tws.Route(ws.GET(\"/namespace/{namespace-name}/pod/{pod-name}/{metric-name}\").\n+\t\tTo(a.podMetrics).\n+\t\tFilter(compressionFilter).\n+\t\tDoc(\"export all aggregated pod-level metrics\").\n+\t\tOperation(\"podMetrics\").\n+\t\tParam(ws.PathParameter(\"namespace-name\", \"The name of the namespace to use\").DataType(\"string\")).\n+\t\tParam(ws.PathParameter(\"pod-name\", \"The name of the pod to use\").DataType(\"string\")).\n+\t\tParam(ws.PathParameter(\"metric-name\", \"The name of the requested metric\").DataType(\"string\")).\n+\t\tParam(ws.QueryParameter(\"start\", \"Start time for requested metrics\").DataType(\"string\")).\n+\t\tWrites(MetricResult{}))\n+\n+\t// The /namespace/{}/pod/{}/container endpoint exposes metrics for the Pod Container entity of the model.\n+\tws.Route(ws.GET(\"/namespace/{namespace-name}/pod/{pod-name}/container/{container-name}/{metric-name}\").\n+\t\tTo(a.podContainerMetrics).\n+\t\tFilter(compressionFilter).\n+\t\tDoc(\"export a container-level metric for a pod container\").\n+\t\tOperation(\"podContainerMetrics\").\n+\t\tParam(ws.PathParameter(\"namespace-name\", \"The name of the namespace to use\").DataType(\"string\")).\n+\t\tParam(ws.PathParameter(\"pod-name\", \"The name of the pod to use\").DataType(\"string\")).\n+\t\tParam(ws.PathParameter(\"metric-name\", \"The name of the requested metric\").DataType(\"string\")).\n+\t\tParam(ws.QueryParameter(\"start\", \"Start time for requested metrics\").DataType(\"string\")).\n+\t\tWrites(MetricResult{}))\n+\n+\t// The /node/{}/container endpoint exposes metrics for the Free Container entity of the model.\n+\tws.Route(ws.GET(\"/node/{node-name}/container/{container-name}/{metric-name}\").","path":"api/v1/model_handlers.go","position":99,"original_position":99,"commit_id":"9271c710a0048a444ae8a958201491fb52ebd33e","original_commit_id":"9271c710a0048a444ae8a958201491fb52ebd33e","user":{"login":"rjnagal","id":5420489,"avatar_url":"https://avatars.githubusercontent.com/u/5420489?v=3","gravatar_id":"","url":"https://api.github.com/users/rjnagal","html_url":"https://github.com/rjnagal","followers_url":"https://api.github.com/users/rjnagal/followers","following_url":"https://api.github.com/users/rjnagal/following{/other_user}","gists_url":"https://api.github.com/users/rjnagal/gists{/gist_id}","starred_url":"https://api.github.com/users/rjnagal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjnagal/subscriptions","organizations_url":"https://api.github.com/users/rjnagal/orgs","repos_url":"https://api.github.com/users/rjnagal/repos","events_url":"https://api.github.com/users/rjnagal/events{/privacy}","received_events_url":"https://api.github.com/users/rjnagal/received_events","type":"User","site_admin":false},"body":"that this calls returns only free containers and not all containers is confusing. rename?","created_at":"2015-07-15T21:06:36Z","updated_at":"2015-07-15T21:06:36Z","html_url":"https://github.com/GoogleCloudPlatform/heapster/pull/417#discussion_r34729302","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/417","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/comments/34729302"},"html":{"href":"https://github.com/GoogleCloudPlatform/heapster/pull/417#discussion_r34729302"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/417"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/417","id":39966879,"html_url":"https://github.com/GoogleCloudPlatform/heapster/pull/417","diff_url":"https://github.com/GoogleCloudPlatform/heapster/pull/417.diff","patch_url":"https://github.com/GoogleCloudPlatform/heapster/pull/417.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/issues/417","number":417,"state":"open","locked":false,"title":"[Model 7] REST endpoints","user":{"login":"afein","id":680441,"avatar_url":"https://avatars.githubusercontent.com/u/680441?v=3","gravatar_id":"","url":"https://api.github.com/users/afein","html_url":"https://github.com/afein","followers_url":"https://api.github.com/users/afein/followers","following_url":"https://api.github.com/users/afein/following{/other_user}","gists_url":"https://api.github.com/users/afein/gists{/gist_id}","starred_url":"https://api.github.com/users/afein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afein/subscriptions","organizations_url":"https://api.github.com/users/afein/orgs","repos_url":"https://api.github.com/users/afein/repos","events_url":"https://api.github.com/users/afein/events{/privacy}","received_events_url":"https://api.github.com/users/afein/received_events","type":"User","site_admin":false},"body":"Part 7 of #342 \r\n\r\nThis PR implements the initial set of Getter methods for the model, as well as their corresponding REST endpoints. \r\n\r\nSuggested reading order:\r\n- model/types.go\r\n- api/v1/api.go\r\n- api/v1/model_types.go\r\n- api/v1/model_handlers.go\r\n- models/impl.go\r\n- models/impl_test.go\r\n- manager/manager.go\r\n- heapster.go\r\n- models/util.go\r\n- models/util_test.go\r\n- store/cma_store.go\r\n- store/cma_store_test.go\r\n\r\nThe rework of parseMetrics and InfoType is still a WIP, as it was aiming to correctly calculate instantaneous cpu usage from the cumulative metric counterpart. This is not achieved with the existing implementation, but might be addressed in a future commit on this same PR (unless merged early!)\r\n\r\n\\cc @rjnagal @vmarmol ","created_at":"2015-07-14T21:48:15Z","updated_at":"2015-07-15T21:06:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c1dde79a5706e27854723fe10349ae7ca4dcc046","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/417/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/417/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/issues/417/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/statuses/9271c710a0048a444ae8a958201491fb52ebd33e","head":{"label":"afein:model7","ref":"model7","sha":"9271c710a0048a444ae8a958201491fb52ebd33e","user":{"login":"afein","id":680441,"avatar_url":"https://avatars.githubusercontent.com/u/680441?v=3","gravatar_id":"","url":"https://api.github.com/users/afein","html_url":"https://github.com/afein","followers_url":"https://api.github.com/users/afein/followers","following_url":"https://api.github.com/users/afein/following{/other_user}","gists_url":"https://api.github.com/users/afein/gists{/gist_id}","starred_url":"https://api.github.com/users/afein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afein/subscriptions","organizations_url":"https://api.github.com/users/afein/orgs","repos_url":"https://api.github.com/users/afein/repos","events_url":"https://api.github.com/users/afein/events{/privacy}","received_events_url":"https://api.github.com/users/afein/received_events","type":"User","site_admin":false},"repo":{"id":36956080,"name":"heapster","full_name":"afein/heapster","owner":{"login":"afein","id":680441,"avatar_url":"https://avatars.githubusercontent.com/u/680441?v=3","gravatar_id":"","url":"https://api.github.com/users/afein","html_url":"https://github.com/afein","followers_url":"https://api.github.com/users/afein/followers","following_url":"https://api.github.com/users/afein/following{/other_user}","gists_url":"https://api.github.com/users/afein/gists{/gist_id}","starred_url":"https://api.github.com/users/afein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afein/subscriptions","organizations_url":"https://api.github.com/users/afein/orgs","repos_url":"https://api.github.com/users/afein/repos","events_url":"https://api.github.com/users/afein/events{/privacy}","received_events_url":"https://api.github.com/users/afein/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/afein/heapster","description":"Monitor container resource usage of a Kubernetes cluster","fork":true,"url":"https://api.github.com/repos/afein/heapster","forks_url":"https://api.github.com/repos/afein/heapster/forks","keys_url":"https://api.github.com/repos/afein/heapster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/afein/heapster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/afein/heapster/teams","hooks_url":"https://api.github.com/repos/afein/heapster/hooks","issue_events_url":"https://api.github.com/repos/afein/heapster/issues/events{/number}","events_url":"https://api.github.com/repos/afein/heapster/events","assignees_url":"https://api.github.com/repos/afein/heapster/assignees{/user}","branches_url":"https://api.github.com/repos/afein/heapster/branches{/branch}","tags_url":"https://api.github.com/repos/afein/heapster/tags","blobs_url":"https://api.github.com/repos/afein/heapster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/afein/heapster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/afein/heapster/git/refs{/sha}","trees_url":"https://api.github.com/repos/afein/heapster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/afein/heapster/statuses/{sha}","languages_url":"https://api.github.com/repos/afein/heapster/languages","stargazers_url":"https://api.github.com/repos/afein/heapster/stargazers","contributors_url":"https://api.github.com/repos/afein/heapster/contributors","subscribers_url":"https://api.github.com/repos/afein/heapster/subscribers","subscription_url":"https://api.github.com/repos/afein/heapster/subscription","commits_url":"https://api.github.com/repos/afein/heapster/commits{/sha}","git_commits_url":"https://api.github.com/repos/afein/heapster/git/commits{/sha}","comments_url":"https://api.github.com/repos/afein/heapster/comments{/number}","issue_comment_url":"https://api.github.com/repos/afein/heapster/issues/comments{/number}","contents_url":"https://api.github.com/repos/afein/heapster/contents/{+path}","compare_url":"https://api.github.com/repos/afein/heapster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/afein/heapster/merges","archive_url":"https://api.github.com/repos/afein/heapster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/afein/heapster/downloads","issues_url":"https://api.github.com/repos/afein/heapster/issues{/number}","pulls_url":"https://api.github.com/repos/afein/heapster/pulls{/number}","milestones_url":"https://api.github.com/repos/afein/heapster/milestones{/number}","notifications_url":"https://api.github.com/repos/afein/heapster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/afein/heapster/labels{/name}","releases_url":"https://api.github.com/repos/afein/heapster/releases{/id}","created_at":"2015-06-05T21:24:01Z","updated_at":"2015-06-05T21:24:02Z","pushed_at":"2015-07-15T19:08:59Z","git_url":"git://github.com/afein/heapster.git","ssh_url":"git@github.com:afein/heapster.git","clone_url":"https://github.com/afein/heapster.git","svn_url":"https://github.com/afein/heapster","homepage":"","size":19759,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"GoogleCloudPlatform:master","ref":"master","sha":"ab239c5ef6aa660e45c3b34ead4e3310a4b00ab9","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":23272510,"name":"heapster","full_name":"GoogleCloudPlatform/heapster","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/heapster","description":"Monitor container resource usage of a Kubernetes cluster","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/heapster","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/heapster/releases{/id}","created_at":"2014-08-24T03:50:18Z","updated_at":"2015-07-13T15:14:03Z","pushed_at":"2015-07-15T20:58:11Z","git_url":"git://github.com/GoogleCloudPlatform/heapster.git","ssh_url":"git@github.com:GoogleCloudPlatform/heapster.git","clone_url":"https://github.com/GoogleCloudPlatform/heapster.git","svn_url":"https://github.com/GoogleCloudPlatform/heapster","homepage":"","size":21912,"stargazers_count":338,"watchers_count":338,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":86,"mirror_url":null,"open_issues_count":76,"forks":86,"open_issues":76,"watchers":338,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/417"},"html":{"href":"https://github.com/GoogleCloudPlatform/heapster/pull/417"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/issues/417"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/issues/417/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/417/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/pulls/417/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/heapster/statuses/9271c710a0048a444ae8a958201491fb52ebd33e"}}}}