metrics-clojure-health will allow you to define and run healthcheck.


metrics-clojure-health is provided as a separate package from metrics.core. To install add the following to your project.clj:

[metrics-clojure-health "2.10.0"]


An example using the default HealthCheckRegistry, (which is different from the default-registry).:

(require '[ :as health])
(defhealthcheck "second-check" (fn [] (let [now (.getSeconds (java.util.Date.))]
                                         (if (< now 30)
                                            (health/healthy "%d is less than 30!" now)
                                            (health/unhealthy "%d is more than 30!" now)))))

(health/check second-check)
#_ => #<Result Result{isHealthy=true, message=3 is less than 30!}>

#_ => {:healthy [#<UnmodifiableEntry foo=Result{isHealthy=true, message=6 is less than 30!}>]}