A simple Rack middleware for checking application health.
A simple Rack middleware for checking application health.
A simple Rack middleware for checking application health. Pinglish
exposes a /_ping resource via HTTP GET, returning JSON that
conforms to the spec below.
The application must respond to GET /_ping as an HTTP request.
The request handler should check the health of all services the application depends on, answering questions like, "Can I query against my MySQL database," "Can I create/read keys in Redis," or "How many docs are in my ElasticSearch index?"
The response must return within 29 seconds. This is one second less than the default timeout for many monitoring services.
The response must return an HTTP 200 OK status code if all
health checks pass.
The response must return an HTTP 503 SERVICE UNAVAILABLE
status code if any health checks fail.
The response must be of Content-Type application/json; charset=UTF-8.
The response must be valid JSON no matter what, even if JSON serialization or other fundamental code fails.
The response must contain a "status" key set either to "ok"
or "failures".
The response must contain a "now" key set to the current
server's time in seconds since epoch as a string.
If the "status" key is set to "failures", the response may
contain a "failures" key set to an Array of string names
representing failed checks.
If the "status" key is set to "failures", the response may
contain a "timeouts" key set to an Array of string names
representing checks that exceeded an implementation-specific
individual timeout.
The response body may contain any other top-level keys to supply additional data about services the application consumes, but all values must be strings, arrays of strings, or hashes where both keys and values are strings.
{
// These two keys will always exist.
"now": "1359055102",
"status": "failures",
// This key may only exist when a named check has failed.
"failures": ["db"],
// This key may only exist when a named check exceeds its timeout.
"timeouts": ["really-long-check"],
// Keys like this may exist to provide extra information about
// healthy services, like the number of objects in an S3 bucket.
"s3": "127"
}…No open issues yet, or sync has not completed.