Health Checks¶
New in version 6.0.
Monitoring and auto-scaling services can check Review Board to make sure it’s healthy.
A healthy Review Board instance is serving requests and can connect to its database(s) and cache server(s).
Access to the health check endpoint is restricted by IP address.
We’ll walk through how to perform a health check and how to configure access.
Performing Health Checks¶
To check a Review Board server’s health, perform a HTTP GET on the
/health/
endpoint on your server (for example:
https://reviews.example.com/health/
).
This will return an HTTP status code and JSON payload representing the health of the Review Board server.
A healthy server will send a HTTP 200 OK response with the following JSON payload:
{
"checks": {
"cache.default": "UP",
"database.default": "UP"
},
"errors": {},
"status": "UP"
}
A server that’s failing will send a HTTP 503 Service Unavailable response with a JSON payload looking something like:
{
"checks": {
"cache.default": "DOWN",
"database.default": "DOWN"
},
"errors": {
"cache.default": "Unable to communicate with the cache server",
"database.default": "Connection timed out"
},
"status": "DOWN"
}
If any services are down, the main status
field will be DOWN
.
Docker¶
Our official Docker images are pre-configured to perform health checks.
To enable this in your own image, run:
HEALTHCHECK CMD curl -f http://127.0.0.1/health/ || exit 1
If this is being configured on an external server, make sure to use the correct URL above and configure access to the health check endpoint.
You can configure the interval between health checks, how long until the first health check, and how many failures until a server is considered unhealthy. See the Docker HEALTHCHECK documentation for instructions.
Kubernetes¶
You can configure a HTTP liveness probe in Kubernetes to check Review Board’s health. Note that you may need to configure access to the health check endpoint for your pod.
A liveness probe may look like:
apiVersion: v1
kind: Pod
metadata:
name: reviewboard-liveness-http
labels:
test: liveness
spec:
containers:
- name: liveness
image: k8s.gcr.io/liveness
args:
- /server
livenessProbe:
httpGet:
path: /health/
port: 8080
You can configure the interval between health checks, how long until the first health check, and how many failures until a server is considered unhealthy. See the Kubernetes liveness probe documentation for instructions.
Configuring Access¶
By default, health checks can only be accessed by clients on the same server,
using http://127.0.0.1/health/
or http://[::1]/health/
.
To allow external servers to check the health of Review Board, you will need
to add its IP address to HEALTHCHECK_IPS
in your site directory’s
conf/settings_local.py
file.
For example:
HEALTHCHECK_IPS = [
'10.0.1.20',
]