Medical Examination - application for register health check callbacks and represent their state via HTTP.
-
Add medex to your list of dependencies in
mix.exs
:def deps do [{:medex, github: "xerions/medex"}] end
-
Ensure medex is started before your application:
def application do [applications: [:medex]] end
Register new check callback:
Medex.register "db", fn ->
case :erlang.phash2(:erlang.now, 3) do
0 -> :ok
1 -> :warning
2 -> :critical
end
end
and get state
$ curl -v http://localhost:4000/health/db
Medex suports pushing health check statutes to Consul. It is disabled by default but you can turn it on:
# use consul, false by default
config :medex, consul: true
# which service name will be using for consul health-checks (optional)
config :medex, service_id: "service_example"
And ensure start of consul application.