{"action":"created","comment":{"url":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/comments/42978545","id":42978545,"diff_hunk":"@@ -697,3 +699,122 @@ Bulk import only works on documents in our persistent data storage layer.\n   }\n }\n ```\n+\n+---\n+\n+### Getting the last statistics frame\n+\n+Kuzzle monitors its internal activities and make snapshots of them. This command allows getting the last stored statistics frame.\n+\n+These statistics include:\n+\n+* the number of connected users for protocols allowing this notion (websocket, udp, ...)\n+* the number of ongoing requests\n+* the number of completed requests since the last frame\n+* the number of failed requests since the last frame\n+\n+**URL:** ``http://kuzzle:7512/api/_getStats``\n+\n+**Method:** ``GET``\n+\n+**Response:**\n+\n+```javascript\n+{\n+  error: null,                      // Assuming everything went well\n+  result: {\n+    count: <number of found documents>\n+    _source: {                      // Your original count query\n+      ...\n+    },\n+    collection: '<data collection>',\n+    action: 'getStats',\n+    controller: 'admin',\n+    statistics: {\n+      \"YYYY-MM-DDTHH:mm:ss.mmmZ\": {","path":"docs/API.REST.md","position":45,"original_position":45,"commit_id":"db3572c3dd2fb6d48c16182ab8a06be4c359c970","original_commit_id":"db3572c3dd2fb6d48c16182ab8a06be4c359c970","user":{"login":"scottinet","id":12997967,"avatar_url":"https://avatars.githubusercontent.com/u/12997967?v=3","gravatar_id":"","url":"https://api.github.com/users/scottinet","html_url":"https://github.com/scottinet","followers_url":"https://api.github.com/users/scottinet/followers","following_url":"https://api.github.com/users/scottinet/following{/other_user}","gists_url":"https://api.github.com/users/scottinet/gists{/gist_id}","starred_url":"https://api.github.com/users/scottinet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottinet/subscriptions","organizations_url":"https://api.github.com/users/scottinet/orgs","repos_url":"https://api.github.com/users/scottinet/repos","events_url":"https://api.github.com/users/scottinet/events{/privacy}","received_events_url":"https://api.github.com/users/scottinet/received_events","type":"User","site_admin":false},"body":"This was the easiest way I found to be able to easily sort frames when getting multiple statistics frames. And since I decided that getStats and getAllStats should return the same answer structure, here it is.\r\n\r\nAnother way to format these responses could be to return an array of statistics:\r\n\r\n```\r\n{\r\n  error: null,\r\n  result: {\r\n    ...\r\n  statistics: [\r\n    {\"timestamp\": \"YYYY-MM-DDTHH:mm:ss.mmm\",   ... statistics informations ...},\r\n    {\"timestamp\": \"YYYY-MM-DDTHH:mm:ss.mmm\",   ... statistics informations ...},\r\n    {\"timestamp\": \"YYYY-MM-DDTHH:mm:ss.mmm\",   ... statistics informations ...},\r\n    ...\r\n  ],\r\n```\r\n","created_at":"2015-10-26T10:45:37Z","updated_at":"2015-10-26T10:45:37Z","html_url":"https://github.com/kuzzleio/kuzzle/pull/45#discussion_r42978545","pull_request_url":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/45","_links":{"self":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/comments/42978545"},"html":{"href":"https://github.com/kuzzleio/kuzzle/pull/45#discussion_r42978545"},"pull_request":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/45"}}},"pull_request":{"url":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/45","id":48208006,"html_url":"https://github.com/kuzzleio/kuzzle/pull/45","diff_url":"https://github.com/kuzzleio/kuzzle/pull/45.diff","patch_url":"https://github.com/kuzzleio/kuzzle/pull/45.patch","issue_url":"https://api.github.com/repos/kuzzleio/kuzzle/issues/45","number":45,"state":"open","locked":false,"title":"Statistics","user":{"login":"scottinet","id":12997967,"avatar_url":"https://avatars.githubusercontent.com/u/12997967?v=3","gravatar_id":"","url":"https://api.github.com/users/scottinet","html_url":"https://github.com/scottinet","followers_url":"https://api.github.com/users/scottinet/followers","following_url":"https://api.github.com/users/scottinet/following{/other_user}","gists_url":"https://api.github.com/users/scottinet/gists{/gist_id}","starred_url":"https://api.github.com/users/scottinet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottinet/subscriptions","organizations_url":"https://api.github.com/users/scottinet/orgs","repos_url":"https://api.github.com/users/scottinet/repos","events_url":"https://api.github.com/users/scottinet/events{/privacy}","received_events_url":"https://api.github.com/users/scottinet/received_events","type":"User","site_admin":false},"body":"* Added the \"statistics\" core component: now Kuzzle monitors ongoing/completed/failed requests by protocols, and active connections. Statistics are saved every 10s by default and are kept for 1hr\r\n* Added ``getStats`` admin action, allowing to retrieve the last saved statistics frame\r\n* Added ``getAllStats`` admin action, allowing to retrieve all saved statistics\r\n* Refactored the way we use the Redis service to allow multiple cache databases\r\n* Added new redis service capabilities to handle volatile keys\r\n* Updated unit and functional tests\r\n* Updated API documentations\r\n* Fixed uses of captains-log in the bin/kuzzle* scripts\r\n* Fixed jshint grunt configuration to use the .jshintrc file instead of the defautl configuration\r\n","created_at":"2015-10-20T14:27:25Z","updated_at":"2015-10-26T10:45:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1fe661fad29e013f870b0b91e3e0eba5c3517106","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/45/commits","review_comments_url":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/45/comments","review_comment_url":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kuzzleio/kuzzle/issues/45/comments","statuses_url":"https://api.github.com/repos/kuzzleio/kuzzle/statuses/db3572c3dd2fb6d48c16182ab8a06be4c359c970","head":{"label":"kuzzleio:statistics","ref":"statistics","sha":"db3572c3dd2fb6d48c16182ab8a06be4c359c970","user":{"login":"kuzzleio","id":12933347,"avatar_url":"https://avatars.githubusercontent.com/u/12933347?v=3","gravatar_id":"","url":"https://api.github.com/users/kuzzleio","html_url":"https://github.com/kuzzleio","followers_url":"https://api.github.com/users/kuzzleio/followers","following_url":"https://api.github.com/users/kuzzleio/following{/other_user}","gists_url":"https://api.github.com/users/kuzzleio/gists{/gist_id}","starred_url":"https://api.github.com/users/kuzzleio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuzzleio/subscriptions","organizations_url":"https://api.github.com/users/kuzzleio/orgs","repos_url":"https://api.github.com/users/kuzzleio/repos","events_url":"https://api.github.com/users/kuzzleio/events{/privacy}","received_events_url":"https://api.github.com/users/kuzzleio/received_events","type":"Organization","site_admin":false},"repo":{"id":41084349,"name":"kuzzle","full_name":"kuzzleio/kuzzle","owner":{"login":"kuzzleio","id":12933347,"avatar_url":"https://avatars.githubusercontent.com/u/12933347?v=3","gravatar_id":"","url":"https://api.github.com/users/kuzzleio","html_url":"https://github.com/kuzzleio","followers_url":"https://api.github.com/users/kuzzleio/followers","following_url":"https://api.github.com/users/kuzzleio/following{/other_user}","gists_url":"https://api.github.com/users/kuzzleio/gists{/gist_id}","starred_url":"https://api.github.com/users/kuzzleio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuzzleio/subscriptions","organizations_url":"https://api.github.com/users/kuzzleio/orgs","repos_url":"https://api.github.com/users/kuzzleio/repos","events_url":"https://api.github.com/users/kuzzleio/events{/privacy}","received_events_url":"https://api.github.com/users/kuzzleio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kuzzleio/kuzzle","description":"Open-source Back-end as a Service - Real-time, storage, advanced search - Web, Apps, Mobile, IoT","fork":false,"url":"https://api.github.com/repos/kuzzleio/kuzzle","forks_url":"https://api.github.com/repos/kuzzleio/kuzzle/forks","keys_url":"https://api.github.com/repos/kuzzleio/kuzzle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kuzzleio/kuzzle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kuzzleio/kuzzle/teams","hooks_url":"https://api.github.com/repos/kuzzleio/kuzzle/hooks","issue_events_url":"https://api.github.com/repos/kuzzleio/kuzzle/issues/events{/number}","events_url":"https://api.github.com/repos/kuzzleio/kuzzle/events","assignees_url":"https://api.github.com/repos/kuzzleio/kuzzle/assignees{/user}","branches_url":"https://api.github.com/repos/kuzzleio/kuzzle/branches{/branch}","tags_url":"https://api.github.com/repos/kuzzleio/kuzzle/tags","blobs_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/refs{/sha}","trees_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kuzzleio/kuzzle/statuses/{sha}","languages_url":"https://api.github.com/repos/kuzzleio/kuzzle/languages","stargazers_url":"https://api.github.com/repos/kuzzleio/kuzzle/stargazers","contributors_url":"https://api.github.com/repos/kuzzleio/kuzzle/contributors","subscribers_url":"https://api.github.com/repos/kuzzleio/kuzzle/subscribers","subscription_url":"https://api.github.com/repos/kuzzleio/kuzzle/subscription","commits_url":"https://api.github.com/repos/kuzzleio/kuzzle/commits{/sha}","git_commits_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/commits{/sha}","comments_url":"https://api.github.com/repos/kuzzleio/kuzzle/comments{/number}","issue_comment_url":"https://api.github.com/repos/kuzzleio/kuzzle/issues/comments{/number}","contents_url":"https://api.github.com/repos/kuzzleio/kuzzle/contents/{+path}","compare_url":"https://api.github.com/repos/kuzzleio/kuzzle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kuzzleio/kuzzle/merges","archive_url":"https://api.github.com/repos/kuzzleio/kuzzle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kuzzleio/kuzzle/downloads","issues_url":"https://api.github.com/repos/kuzzleio/kuzzle/issues{/number}","pulls_url":"https://api.github.com/repos/kuzzleio/kuzzle/pulls{/number}","milestones_url":"https://api.github.com/repos/kuzzleio/kuzzle/milestones{/number}","notifications_url":"https://api.github.com/repos/kuzzleio/kuzzle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kuzzleio/kuzzle/labels{/name}","releases_url":"https://api.github.com/repos/kuzzleio/kuzzle/releases{/id}","created_at":"2015-08-20T08:26:57Z","updated_at":"2015-10-25T09:15:20Z","pushed_at":"2015-10-26T10:33:03Z","git_url":"git://github.com/kuzzleio/kuzzle.git","ssh_url":"git@github.com:kuzzleio/kuzzle.git","clone_url":"https://github.com/kuzzleio/kuzzle.git","svn_url":"https://github.com/kuzzleio/kuzzle","homepage":"http://www.kuzzle.io","size":3664,"stargazers_count":40,"watchers_count":40,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":40,"default_branch":"master"}},"base":{"label":"kuzzleio:master","ref":"master","sha":"0197c526b0e96698f0f401ddcda2304f249252e7","user":{"login":"kuzzleio","id":12933347,"avatar_url":"https://avatars.githubusercontent.com/u/12933347?v=3","gravatar_id":"","url":"https://api.github.com/users/kuzzleio","html_url":"https://github.com/kuzzleio","followers_url":"https://api.github.com/users/kuzzleio/followers","following_url":"https://api.github.com/users/kuzzleio/following{/other_user}","gists_url":"https://api.github.com/users/kuzzleio/gists{/gist_id}","starred_url":"https://api.github.com/users/kuzzleio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuzzleio/subscriptions","organizations_url":"https://api.github.com/users/kuzzleio/orgs","repos_url":"https://api.github.com/users/kuzzleio/repos","events_url":"https://api.github.com/users/kuzzleio/events{/privacy}","received_events_url":"https://api.github.com/users/kuzzleio/received_events","type":"Organization","site_admin":false},"repo":{"id":41084349,"name":"kuzzle","full_name":"kuzzleio/kuzzle","owner":{"login":"kuzzleio","id":12933347,"avatar_url":"https://avatars.githubusercontent.com/u/12933347?v=3","gravatar_id":"","url":"https://api.github.com/users/kuzzleio","html_url":"https://github.com/kuzzleio","followers_url":"https://api.github.com/users/kuzzleio/followers","following_url":"https://api.github.com/users/kuzzleio/following{/other_user}","gists_url":"https://api.github.com/users/kuzzleio/gists{/gist_id}","starred_url":"https://api.github.com/users/kuzzleio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kuzzleio/subscriptions","organizations_url":"https://api.github.com/users/kuzzleio/orgs","repos_url":"https://api.github.com/users/kuzzleio/repos","events_url":"https://api.github.com/users/kuzzleio/events{/privacy}","received_events_url":"https://api.github.com/users/kuzzleio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kuzzleio/kuzzle","description":"Open-source Back-end as a Service - Real-time, storage, advanced search - Web, Apps, Mobile, IoT","fork":false,"url":"https://api.github.com/repos/kuzzleio/kuzzle","forks_url":"https://api.github.com/repos/kuzzleio/kuzzle/forks","keys_url":"https://api.github.com/repos/kuzzleio/kuzzle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kuzzleio/kuzzle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kuzzleio/kuzzle/teams","hooks_url":"https://api.github.com/repos/kuzzleio/kuzzle/hooks","issue_events_url":"https://api.github.com/repos/kuzzleio/kuzzle/issues/events{/number}","events_url":"https://api.github.com/repos/kuzzleio/kuzzle/events","assignees_url":"https://api.github.com/repos/kuzzleio/kuzzle/assignees{/user}","branches_url":"https://api.github.com/repos/kuzzleio/kuzzle/branches{/branch}","tags_url":"https://api.github.com/repos/kuzzleio/kuzzle/tags","blobs_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/refs{/sha}","trees_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kuzzleio/kuzzle/statuses/{sha}","languages_url":"https://api.github.com/repos/kuzzleio/kuzzle/languages","stargazers_url":"https://api.github.com/repos/kuzzleio/kuzzle/stargazers","contributors_url":"https://api.github.com/repos/kuzzleio/kuzzle/contributors","subscribers_url":"https://api.github.com/repos/kuzzleio/kuzzle/subscribers","subscription_url":"https://api.github.com/repos/kuzzleio/kuzzle/subscription","commits_url":"https://api.github.com/repos/kuzzleio/kuzzle/commits{/sha}","git_commits_url":"https://api.github.com/repos/kuzzleio/kuzzle/git/commits{/sha}","comments_url":"https://api.github.com/repos/kuzzleio/kuzzle/comments{/number}","issue_comment_url":"https://api.github.com/repos/kuzzleio/kuzzle/issues/comments{/number}","contents_url":"https://api.github.com/repos/kuzzleio/kuzzle/contents/{+path}","compare_url":"https://api.github.com/repos/kuzzleio/kuzzle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kuzzleio/kuzzle/merges","archive_url":"https://api.github.com/repos/kuzzleio/kuzzle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kuzzleio/kuzzle/downloads","issues_url":"https://api.github.com/repos/kuzzleio/kuzzle/issues{/number}","pulls_url":"https://api.github.com/repos/kuzzleio/kuzzle/pulls{/number}","milestones_url":"https://api.github.com/repos/kuzzleio/kuzzle/milestones{/number}","notifications_url":"https://api.github.com/repos/kuzzleio/kuzzle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kuzzleio/kuzzle/labels{/name}","releases_url":"https://api.github.com/repos/kuzzleio/kuzzle/releases{/id}","created_at":"2015-08-20T08:26:57Z","updated_at":"2015-10-25T09:15:20Z","pushed_at":"2015-10-26T10:33:03Z","git_url":"git://github.com/kuzzleio/kuzzle.git","ssh_url":"git@github.com:kuzzleio/kuzzle.git","clone_url":"https://github.com/kuzzleio/kuzzle.git","svn_url":"https://github.com/kuzzleio/kuzzle","homepage":"http://www.kuzzle.io","size":3664,"stargazers_count":40,"watchers_count":40,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/45"},"html":{"href":"https://github.com/kuzzleio/kuzzle/pull/45"},"issue":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/issues/45"},"comments":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/issues/45/comments"},"review_comments":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/45/comments"},"review_comment":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/pulls/45/commits"},"statuses":{"href":"https://api.github.com/repos/kuzzleio/kuzzle/statuses/db3572c3dd2fb6d48c16182ab8a06be4c359c970"}}}}