Health checks#
A health check is a question something else asks the server again and again: are you there? A load balancer asks it to know where to send users. An orchestrator such as Kubernetes asks it to know when to restart a container. A monitoring system asks it to know when to wake somebody.
CrushMFT 27 answers two such questions, on its web ports, without a login.
The two addresses#
| Address | Answers | Use it for |
|---|---|---|
/WebInterface/api/healthz |
200 and {"status":"ok"} while the server's process answers |
liveness: is it alive? If not, restart it. |
/WebInterface/api/readyz |
200 and {"status":"ready"} when the server has loaded its settings, at least one of its ports is running and it is not shutting down. 503 and {"status":"not_ready"} otherwise. |
readiness: should it get users? If not, send them elsewhere and wait. |
On a test server:
$ curl -s http://127.0.0.1:18080/WebInterface/api/healthz
{"status":"ok"}
$ curl -s http://127.0.0.1:18080/WebInterface/api/readyz
{"status":"ready"}
- They need no login, no cookie and no token, and start no session. A probe every few seconds leaves nothing behind.
- They are on every HTTP and HTTPS port of the server.
- They say only "ok" or "ready": nothing about the server that an outsider should not know.
| Server setting | Does | Unless you change it |
|---|---|---|
api_health |
answers the two addresses. false: they answer 404. |
true |
The difference between the two matters while the server starts and stops. A server that is starting is alive and not ready; one that was told to shut down is alive and no longer ready. A load balancer that asks readyz takes a server out before it goes down, and puts it back only when it can serve.
A load balancer#
Point the load balancer's health check at readyz, expect 200, every 5 to 10 seconds. Two or three failures in a row take a server out.
CrushBalance, the load balancer for CrushMFT, has health checks of its own: see its wiki.
A plain TCP check, "does the port open", is not enough: a server can accept connections while it is not ready to serve them.
A container#
The images of CrushMFT 27 have no shell and no curl, so the usual health check of Docker cannot be written with them. The image brings a small program for it, and the chart for Kubernetes sets its probes on these two addresses. See Health, logs and monitoring in the Docker wiki.
A monitoring system#
Any monitoring that can fetch an address can use these: expect 200 from readyz.
For more than up or down, three further sources:
| Source | Gives | Needs |
|---|---|---|
| Prometheus metrics | crushmft_health_ok per check, and the server's other numbers |
a token or an allowed address; an Enterprise licence |
| the API | GET /server/status: the server's state with health_overall, health_job_engine, health_replication, health_serverbeat, sessions, memory, threads |
an access token |
| alerts | the server tells you itself | a recipient |
The health of the parts#
Inside, the server keeps a state for each of its parts that can be impaired while the server as a whole still answers:
| Check | Is about |
|---|---|
job_engine |
the program that runs jobs: see Job engines |
replication |
the exchange with the other servers of a cluster |
serverbeat |
the shared address of a cluster |
overall |
the worst of them |
Each is OK, DISABLED when the part is not in use, or says what is wrong. They are shown on the Status page of the admin pages, are in the metrics and the API, and can be watched by an alert: Watching a variable.
readyz is about the server serving users. A job engine that is down does not make the server "not ready": users can still log in and transfer. Watch the parts as well.
Things to know#
- From outside is the only real test. A server that is cut off from the network sends no alert that arrives. Something outside it has to ask.
- Through a reverse proxy, the two addresses are reached like any other page. If the proxy rewrites paths, let its own check ask the server directly.
- Do not use the login page as a health check. A request for
/starts an anonymous session each time. The two addresses were made so that nothing has to. - A DMZ server answers the two addresses for itself. That it is ready says nothing about the internal server behind it: check both.
- Versions. The addresses are new in CrushMFT 27. Checks written for version 11, which fetched the login page, should be changed.