{"action":"created","issue":{"url":"https://api.github.com/repos/apiman/apiman/issues/160","labels_url":"https://api.github.com/repos/apiman/apiman/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/apiman/apiman/issues/160/comments","events_url":"https://api.github.com/repos/apiman/apiman/issues/160/events","html_url":"https://github.com/apiman/apiman/issues/160","id":94964645,"number":160,"title":"Metrics API for hits per resource","user":{"login":"cen1","id":1158861,"avatar_url":"https://avatars.githubusercontent.com/u/1158861?v=3","gravatar_id":"","url":"https://api.github.com/users/cen1","html_url":"https://github.com/cen1","followers_url":"https://api.github.com/users/cen1/followers","following_url":"https://api.github.com/users/cen1/following{/other_user}","gists_url":"https://api.github.com/users/cen1/gists{/gist_id}","starred_url":"https://api.github.com/users/cen1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cen1/subscriptions","organizations_url":"https://api.github.com/users/cen1/orgs","repos_url":"https://api.github.com/users/cen1/repos","events_url":"https://api.github.com/users/cen1/events{/privacy}","received_events_url":"https://api.github.com/users/cen1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-14T14:55:12Z","updated_at":"2015-07-14T15:14:41Z","closed_at":"2015-07-14T15:14:41Z","body":"One interesting addition to the Metrics would be to get number of hits per resource. This would tell you which of the endpoints get hit the most. I am new to ElasticSearch but I tried to first write a query to see if I can retrieve this data (very simplified GitHub API used as producer):\r\n```\r\n{\r\n    \"size\": 0,\r\n    \"aggs\" : {\r\n        \"resources\" : {\r\n            \"terms\" : { \r\n                \"field\" : \"resource\"\r\n            }\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nResult:\r\n```\r\n\r\n\r\n    {\r\n        \"took\": 0,\r\n        \"timed_out\": false,\r\n        \"_shards\":\r\n        {\r\n            \"total\": 5,\r\n            \"successful\": 5,\r\n            \"failed\": 0\r\n        },\r\n        \"hits\":\r\n        {\r\n            \"total\": 27,\r\n            \"max_score\": 0,\r\n            \"hits\":\r\n            [\r\n            ]\r\n        },\r\n        \"aggregations\":\r\n        {\r\n            \"resources\":\r\n            {\r\n                \"buckets\":\r\n                [\r\n                    {\r\n                        \"key\": \"cen1\",\r\n                        \"doc_count\": 21\r\n                    },\r\n                    {\r\n                        \"key\": \"users\",\r\n                        \"doc_count\": 13\r\n                    },\r\n                    {\r\n                        \"key\": \"repos\",\r\n                        \"doc_count\": 4\r\n                    },\r\n                    {\r\n                        \"key\": \"user\",\r\n                        \"doc_count\": 2\r\n                    }\r\n                ]\r\n            }\r\n        }\r\n    }\r\n```\r\nThis is not really what we want because ES broke the ```resource``` field apart. What I wanted are the full endpoints: ```/users/cen1``` and ```/users/cen1/repos``` for example. Googling around revealed that this happened because the ```resource``` field is \"analyzed\" and in order to solve the issue it would need to be set to \"not_analyzed\", but that hinders performance. Some other suggestions were multi field types and script field, the latter didn't work for me.\r\n\r\nI'd greatly appreciate if someone with greater ES knowledge could give opinion on this matter.\r\n\r\nhttp://stackoverflow.com/questions/10093638/how-to-prevent-facet-terms-from-tokenizing\r\nhttp://stackoverflow.com/questions/26212808/get-complete-term-contents-with-aggregations-in-elasticsearch"},"comment":{"url":"https://api.github.com/repos/apiman/apiman/issues/comments/121278862","html_url":"https://github.com/apiman/apiman/issues/160#issuecomment-121278862","issue_url":"https://api.github.com/repos/apiman/apiman/issues/160","id":121278862,"user":{"login":"EricWittmann","id":1890703,"avatar_url":"https://avatars.githubusercontent.com/u/1890703?v=3","gravatar_id":"","url":"https://api.github.com/users/EricWittmann","html_url":"https://github.com/EricWittmann","followers_url":"https://api.github.com/users/EricWittmann/followers","following_url":"https://api.github.com/users/EricWittmann/following{/other_user}","gists_url":"https://api.github.com/users/EricWittmann/gists{/gist_id}","starred_url":"https://api.github.com/users/EricWittmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EricWittmann/subscriptions","organizations_url":"https://api.github.com/users/EricWittmann/orgs","repos_url":"https://api.github.com/users/EricWittmann/repos","events_url":"https://api.github.com/users/EricWittmann/events{/privacy}","received_events_url":"https://api.github.com/users/EricWittmann/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T15:14:41Z","updated_at":"2015-07-14T15:14:41Z","body":"https://issues.jboss.org/browse/APIMAN-540"}}