Build StatusCoverage Status || Hex versionHex downloads

PlugCheckup

PlugCheckup provides a Plug for adding simple health checks to your app. The JSON output is similar to the one provided by the MiniCheck Ruby library. It was started at solarisBank as an easy way of providing monitoring to our Plug based applications.

Usage

defp deps do
[
{:plug_checkup, "~> 0.3.0"}
]
end
defmodule MyHealthChecks do
def check_db do
:ok
end
def check_redis do
:ok
end
end
checks = [
%PlugCheckup.Check{name: "DB", module: MyHealthChecks, function: :check_db},
%PlugCheckup.Check{name: "Redis", module: MyHealthChecks, function: :check_redis}
]
forward(
"/health",
to: PlugCheckup,
init_opts: PlugCheckup.Options.new(checks: checks)
)

If you're working with Phoenix, you need to change the syntax slightly to accomodate Phoenix.Router.forward/4:

checks = [
%PlugCheckup.Check{name: "DB", module: MyHealthChecks, function: :check_db},
%PlugCheckup.Check{name: "Redis", module: MyHealthChecks, function: :check_redis}
]
forward("/health", PlugCheckup, PlugCheckup.Options.new(checks: checks))

The Checks

A check is a function with arity zero, which should return either :ok or {:error, term}. In case the check raises an exception or times out, that will be mapped to an {:error, reason} result.

Response

PlugCheckup should return either 200 or 500 statuses, Content-Type header "application/json", and the body should respect this JSON schema