-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
command/agent: Add simple HTTP check type #592
Conversation
These checks make an `HTTP GET` request every Interval to the specified URL. The status of the service depends on the HTTP Response Code. `200` is passing, `503` is warning and anything else is failing.
I believe this type of check was considered in the early days of consul and rejected. I forget on what grounds. I would personally like to see it added. I ended up writing a utility to poll http end points and submit check results to the agent. |
I think is a good idea. @blalor it's possible this was rejected early on, but I've had a change of heart on it.
|
My reasoning for not using 503 is that in many application servers already implement to indicate various critical conditions. e.g. Phusion or uWSGI failing to start the underlying Rails/Django app causes 503. Using 429 requires an app to actually implement it since it's generally not a builtin default, so you cannot accidentally get into the warning state. |
(small request: the ability to see the entire HTTP Request/Response so it can be compared or replayed with telnet(1)). |
For long (>10s) interval checks the http timeout is 10s, otherwise thetimeout is the interval. This means that a check *should* return before the next check begins.
Fixed: Any 2XX status code should be treated as OK Example debug log: Example from |
LGTM! Thanks! |
command/agent: Add simple HTTP check type
We are running 20+ services that all register using consul. Consul then checks each service using curl every second (1s). On some of our lower power (dev and test) machines we are seeing a lot of CPU load from consul forking curl 20 times per second.
Add a simple HTTP check type that makes an
HTTP GET
request every Interval to the specified URL.The status of the service depends on the HTTP Response Code.
200
is passing,503
is warning and anything else is failing.An HTTP based check looks like this:
{
"check": {
"id": "api",
"name": "HTTP API on port 5000 with a /health route",
"http": "http://localhost:5000/health",
"interval": "10s"
}
}