Control health checks and toggle upstream node status in load balancers with ease.
Demo at poolse.vacovsky.us.
Exposes a simple interface to “up” and “down” upstream nodes.
Monitoring of targets can be as simple or complex as needed. HTTP Status code checking, reponse strings parsing, and fail/success thresholds are supported for determining health of upstream nodes.
Multiple status formats are provided, including: 503, no repsonse, as well as partial and full JSON blobs describing the state and parameters per target.
Reconfigure/reload of settings on the fly, without “downing” the node (this is handy when using automation platforms like Chef).
Provides a common format/interface for managing applications which are behind some form of reverse proxy or load balancer that checks at interval for server health status.
go get -u github.com/davecgh/go-spew/spew
git clone https://github.com/vacoj/poolse.git
cd poolse/src/poolse
go build
./poolse /path/to/config.json
{
"state": {
"startup_state": true, // if true, when server starts, if first check passes server state is marked OK
"administrative_state": "AdminOff", // If persistent state isn't on, this is the default statup state for the STATUS. If will only be OK if all Targets are also OK on first check
"persist_state": true // indicates whether or not STATUS.State.AdministrativeState should be sticky between settings/application restarts and reloads.
},
"targets": [
{
"endpoint": "http://localhost:5704/fakehealth", // url to your application's health endpoint
"polling_interval": 15, // polling interval for target endpoint, in seconds
"expected_status_code": 200, // *required* HTTP status code to look for. If this isn't returned when the check happens, we mark OK as false.
"up_count_threshold": 10, // this many failed checks will mark target as online
"down_count_threshold": 10 // this many failed checks will mark target as offline
},
{
"name": "Expected Example",
"endpoint": "http://localhost:5704/fakeexpected", // url to your application's health endpoint
"polling_interval": 20, // polling interval for target endpoint, in seconds
"expected_status_code": 200, // HTTP status code to look for. If this isn't returned when the check happens, we mark OK as false.
"expected_response_strings": ["{\"is_working\": true}"],
"up_count_threshold": 10, // this many failed checks will mark target as online
"down_count_threshold": 10 // this many failed checks will mark target as offline
},
{
"name": "Unexpected Example",
"endpoint": "http://localhost:5704/fakeexpected", // url to your application's health endpoint
"polling_interval": 10, // polling interval for target endpoint, in seconds
"expected_status_code": 200, // HTTP status code to look for. If this isn't returned when the check happens, we mark OK as false.
"unexpected_response_strings": ["{\"is_working\": false}"], // response is parsed for this string. If unexpected_response_string is blank, check is ignored. If found, OK is false (an example would be searching repsonse text for {"thisthing": false}, and if found, causes OK to be set to false)
"up_count_threshold": 10, // this many failed checks will mark target as online
"down_count_threshold": 10 // this many failed checks will mark target as offline
},
{
"name": "Fake Smoke" // Arbitrary - use for your own reasons, or leave it blank.
"endpoint": "http://localhost:5704/fakesmoke", // url to your application's health endpoint
"polling_interval": 300, // polling interval for target endpoint, in seconds
"expected_status_code": 200, // *required* HTTP status code to look for. If this isn't returned when the check happens, we mark OK as false.
}
],
"service": {
"http_port": "5704", // *string not int; port to listen on for incoming web requests
"debug": false, // displays certain pieces of data in console if true
"show_http_log": true, // shows log in console of calls being made if true
"state_file_name": "state.dat", // name of state file. defaults to state.dat if not preset
"follow_redirects": false // whether or not to follow redirects when querying targets
}
}
cd poolse/src/poolse/static
bower install
id
(example: /status/simple?id=1
) to get just the target object at that index; id should correspond to index of target in config file.
{
"State": {
"ok": true,
"startup_state": true,
"persist_state": true,
"administrative_state": ""
},
"Targets": [
{
"id": 0,
"name": "",
"endpoint": "http://localhost",
"polling_interval": 5,
"expected_status_code": 200,
"expected_response_strings": null,
"unexpected_response_strings": null,
"last_ok": "2017-03-23T08:30:51.1019184-07:00",
"last_checked": "2017-03-23T08:30:51.1019184-07:00",
"ok": true,
"up_count": 6987,
"up_count_threshold": 10,
"down_count": 0,
"down_count_threshold": 1
}
],
"Version": "0.3.10"
}