{"action":"created","issue":{"url":"https://api.github.com/repos/rhuss/jolokia/issues/271","repository_url":"https://api.github.com/repos/rhuss/jolokia","labels_url":"https://api.github.com/repos/rhuss/jolokia/issues/271/labels{/name}","comments_url":"https://api.github.com/repos/rhuss/jolokia/issues/271/comments","events_url":"https://api.github.com/repos/rhuss/jolokia/issues/271/events","html_url":"https://github.com/rhuss/jolokia/issues/271","id":163823260,"number":271,"title":"Add simple Health-Check feature","user":{"login":"rhuss","id":99080,"avatar_url":"https://avatars.githubusercontent.com/u/99080?v=3","gravatar_id":"","url":"https://api.github.com/users/rhuss","html_url":"https://github.com/rhuss","followers_url":"https://api.github.com/users/rhuss/followers","following_url":"https://api.github.com/users/rhuss/following{/other_user}","gists_url":"https://api.github.com/users/rhuss/gists{/gist_id}","starred_url":"https://api.github.com/users/rhuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhuss/subscriptions","organizations_url":"https://api.github.com/users/rhuss/orgs","repos_url":"https://api.github.com/users/rhuss/repos","events_url":"https://api.github.com/users/rhuss/events{/privacy}","received_events_url":"https://api.github.com/users/rhuss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-05T10:52:04Z","updated_at":"2016-07-07T07:11:41Z","closed_at":null,"body":"A new configuration option `healthChecks` should be added which can carry a referenced to a JSON file for defining simple health checks. \r\n\r\nSimple mean that no big logic should be added. If more logic is needed then an implementation of https://github.com/rhuss/jolokia-extra/issues/1 should be considered.\r\n\r\nA health-check is a reference to JMX READ or EXEC for getting the value of an MBean's attribute or operation. This value is fetched on behalf of a request and compared against a given value, defined also in the health checks. The health-check has also an option to specify how the value should be evaluated to yield an `OK` or `NOK`. If an exception occurs this is translated to `ERROR`\r\n\r\nMutiple health-checks can be defined. The overall result to the health-check endpoint is `OK` when all health-checks yield ok, or `NOK` if not.\r\n\r\nThe protocol will be enhanced with a new command 'health' (on the same footprint as 'read', 'write', 'list', ...). It yields an error if no health-checks are provided during startup. \r\n\r\nThe health-check configuration also can contain an IP and a Port. If given, the agent will open a new port on the given ip/config (JVM agent only), serving **only** the health check endpoint. This can be used when the regular port is highly secured e.g. with SSL certificates, but still a simple mean for health checks should be available (with no or only lightweight authentication). Checks also carry one or more types which could be selected by a query parameter.\r\n\r\nHere are some possible examples for a configuration and a corresponding JSON response:\r\n\r\n```json\r\n{\r\n  \"host\": \"127.0.0.1\",\r\n  \"port\": \"8779\",\r\n  \"checks\": [\r\n    {\r\n      \"name\": \"Heap Memory Usage\",\r\n      \"types\": [ \"liveness\" ],\r\n      \"request\": {\r\n        \"mbean\": \"java.lang:type=Memory\",\r\n        \"attribute\": \"HeapMemoryUsage\",\r\n        \"path\": \"used\"\r\n      },\r\n      \"rule\": \"${value} < 1232896\"\r\n    },\r\n    {\r\n      \"name\": \"Thread Number\",\r\n      \"types\": [ \"readiness\", \"liveness\" ],\r\n      \"request\": {\r\n        \"mbean\": \"java.lang:type=Threading\",\r\n        \"attribute\": \"ThreadCount\",\r\n        \"rule\": \"${value} > 10\"\r\n      }\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\nand the response could be\r\n\r\n```json\r\n{\r\n    \"result\": \"NOK\",\r\n    \"checks\": [\r\n      {\r\n        \"name\": \"Heap Memory Usage\",\r\n        \"result\": \"OK\",\r\n        \"value\": \"567803\"\r\n      },\r\n      {\r\n        \"name\": \"Thread Number\",\r\n        \"result\": \"NOK\",\r\n        \"value\": \"5\"\r\n      }\r\n    ]\r\n}\r\n```\r\n \r\n"},"comment":{"url":"https://api.github.com/repos/rhuss/jolokia/issues/comments/231000723","html_url":"https://github.com/rhuss/jolokia/issues/271#issuecomment-231000723","issue_url":"https://api.github.com/repos/rhuss/jolokia/issues/271","id":231000723,"user":{"login":"jstrachan","id":30140,"avatar_url":"https://avatars.githubusercontent.com/u/30140?v=3","gravatar_id":"","url":"https://api.github.com/users/jstrachan","html_url":"https://github.com/jstrachan","followers_url":"https://api.github.com/users/jstrachan/followers","following_url":"https://api.github.com/users/jstrachan/following{/other_user}","gists_url":"https://api.github.com/users/jstrachan/gists{/gist_id}","starred_url":"https://api.github.com/users/jstrachan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jstrachan/subscriptions","organizations_url":"https://api.github.com/users/jstrachan/orgs","repos_url":"https://api.github.com/users/jstrachan/repos","events_url":"https://api.github.com/users/jstrachan/events{/privacy}","received_events_url":"https://api.github.com/users/jstrachan/received_events","type":"User","site_admin":false},"created_at":"2016-07-07T07:11:41Z","updated_at":"2016-07-07T07:11:41Z","body":"Agreed. BTW we could query the health check MBeans whenever the health check endpoint is invoked? It keeps the code simpler & avoids a timer/poller? Its not like querying mbeans is particularly slow or anything and its no biggie if a health check doesn't respond for a couple of ms.\r\n\r\nFor Spring health checks we could have a single MBean that matches the jolokia naming convention which just invokes all the spring health checks it can find (and aggregates all the results?). Then its nice and simple and just 1 MBean class? Doing it from the outside of the users app would rock; but I can imagine it could be tricky from a class loading perspective maybe; though I guess its only 1 method thats being invoked on all the health checks."}}
{"actor":{"display_login":"jstrachan"}}