A Golang library that provides Healthchecks for your Go Application.
- Built-in Healthchecks that covers the monitoring of the most common use cases, like databases, HTTP endpoints, Redis, Disk space, and more. Check the list of available checks.
- Built-in HTTP handler compatible with the native
http
package that constructs the Healthcheck endpoint following the RFC Healthcheck specification. - Implement your own custom Healthchecks easily by implementing a simple interface.
- No external dependencies.
go get -u github.com/brpaz/go-healthcheck/v2
To use the library, simply create a new instance of the Healthcheck service, add your desired checks, and expose the healthcheck endpoint using the provided HTTP handler.
package main
import (
"net/http"
"github.com/brpaz/go-healthcheck/v2"
"github.com/brpaz/go-healthcheck/v2/checks/mockcheck"
)
func main() {
// Create your healthchecks.
check1 := mockcheck.NewCheck(
mockcheck.WithName("my-check"),
mockcheck.WithStatus(checks.StatusPass),
)
hc := healthcheck.New(
healthcheck.WithServiceID("my-service"),
healthcheck.WithDescription("My Service"),
healthcheck.WithVersion("1.0.0"),
healthcheck.WithReleaseID("1.0.0-SNAPSHOT"),
healthcheck.WithChecks(mycheck),
)
http.HandleFunc("/health", healthcheck.HealthHandler(hc))
http.ListenAndServe(":8080", nil)
}
For more information about this package and how to use the provided checks, refer to the Documentation.
All contributions are welcome! Please read the CONTRIBUTING file for details on how to contribute.
If you find this project helpful and would like to support its development, there are a few ways you can contribute:
- Email - [email protected]
- Source code: https://github.com/brpaz/go-healthcheck
This project is licensed under the MIT License - see the LICENSE file for details.