Monitor and track health of services, send heartbeats (to-do), and expose status through HTTP endpoint.
Install health using the go get command:
$ go get github.com/gocrumb/health
The package requires no additional dependencies other than Go itself.
hm := health.New(
health.Checks(
http.Head("http://example.com/", http.Period(3*time.Minute)),
mongo.Ping(mongoClient, mongo.Period(1*time.Minute), mongo.ReadPref(rp)),
redis.Ping(redisClient), // Falls back to default period (5 minutes)
),
health.Logger(log.New(os.Stderr, "[Health] ", log.LstdFlags|log.Lmsgprefix)),
health.OnFailure(func() {
log.Fatal("Health check failed; exiting")
}),
)
hm.Start()
Check | Description |
---|---|
http.Head |
Sends HTTP HEAD requests to the given URL. Expects response with status code 2XX. |
mongo.Ping |
Pings MongoDB through the given client. |
redis.Ping |
Pings Redis through the given client. |
Contributions are welcome.
This package is available under the BSD (3-Clause) License.
- Check: TCP connection, fails on disconnect.
- Check: RabbitMQ
- Beacon: Send periodic pings to remote health monitoring service (e.g. healthchecks.io)