A lightweight, framework-independent health check framework for Go microservices.
Most health endpoints only answer one question:
"Is my HTTP server running?"
Production systems need a much more important answer:
- Is the database reachable?
- Is Kafka connected?
- Is RabbitMQ available?
- Is Elasticsearch healthy?
- Is the external HTTP service responding?
- Can this service actually perform its job?
core-go/health provides a simple, extensible, and production-ready way to monitor the health of your application's critical dependencies.
- You can refer to Microservice Health Check at my Linked In for more details.
Many Go applications expose a health endpoint like this:
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})This only indicates that the HTTP server is alive.
Imagine a microservice that depends on:
- Oracle
- Kafka
- Redis
- Elasticsearch
- External HTTP APIs
If Kafka becomes unavailable:
- the HTTP server is still running
/healthstill returns 200 OK- Kubernetes considers the pod healthy
- users begin experiencing failures
- engineers spend valuable time finding the root cause
With core-go/health, the health endpoint immediately reports that Kafka is DOWN, allowing your monitoring platform to notify the correct team before users report problems.
- Lightweight
- Framework independent
- Production-ready
- Kubernetes ready
- Built-in providers for common infrastructure
- Per-provider configurable timeout
- Ready-to-use HTTP handlers
- Pluggable provider architecture
- Easy to extend with custom providers
- Zero dependency on any web framework
Built-in providers include:
- SQL Database
- PostgreSQL
- MySQL
- Oracle
- SQL Server
- MongoDB
- Firestore
- Elasticsearch
- Redis
- Kafka
- RabbitMQ
- IBM MQ
- ActiveMQ
- NATS
- HTTP Client
- Custom Providers
Designed to integrate seamlessly with existing Go libraries: Gorilla mux, Go-chi, Echo and Gin.
| Framework | Supported |
|---|---|
| net/http | ✅ |
| Gin | ✅ |
| Echo | ✅ |
Samples:
- handler, to support Gorilla mux and Go-chi. The sample is at go-sql-sample.
- echo handler to support Echo. The sample is at go-sql-echo-sample.
- gin handler to support Gin. The sample is at go-sql-gin-sample.
http.Handle("/health", health.NewHandler(checker))router.GET("/health", healthgin.NewHandler(checker))e.GET("/health", healthecho.NewHandler(checker))Using another framework?
Simply invoke the health checker and write the response using your preferred framework.
A slow dependency should never block your health endpoint.
Since Kubernetes typically invokes health endpoints every few seconds, every provider supports its own timeout.
health.Add(
kafka.NewChecker(
producer,
4*time.Second,
),
)or
health.Add(
http.NewChecker(
"User Service",
"https://user-service/health",
4*time.Second,
),
)Benefits:
- Prevent hanging health requests
- Detect slow or unreachable services
- Keep Kubernetes probes responsive
- Configure different timeout values for different providers
checker := health.New()
checker.Add(sql.New(database))
checker.Add(redis.New(redisClient))
checker.Add(kafka.New(producer))
checker.Add(elasticsearch.New(client))
checker.Add(http.New(
"User Service",
"https://user-service/health",
))
http.Handle("/health", health.NewHandler(checker))Everything is healthy:
{
"status": "UP",
"services": [
{
"name": "database",
"status": "UP"
},
{
"name": "redis",
"status": "UP"
},
{
"name": "kafka",
"status": "UP"
}
]
}Kafka is unavailable:
{
"status": "DOWN",
"services": [
{
"name": "database",
"status": "UP"
},
{
"name": "redis",
"status": "UP"
},
{
"name": "kafka",
"status": "DOWN",
"error": "connection refused"
}
]
} +-----------------------+
| Health Checker |
+-----------------------+
|
-----------------------------------------------------
| | | | | |
SQL Redis Kafka RabbitMQ HTTP Elasticsearch
| | | | | |
-----------------------------------------------------
|
Health Response
Every provider implements the same interface.
Adding support for a new system only requires implementing a new provider.
Perfect for:
- Kubernetes Readiness Probe
- Kubernetes Liveness Probe
- Docker Health Check
- Amazon ECS
- Google Cloud Run
- Background Workers
- Scheduled Jobs
- REST APIs
- Microservices
Unlike a simple /health endpoint that only checks whether the HTTP server is running, core-go/health verifies the health of the infrastructure your application actually depends on.
This enables you to:
- Detect dependency failures immediately
- Reduce Mean Time To Detect (MTTD)
- Improve production observability
- Simplify troubleshooting
- Standardize health checks across services
- Reuse the same health framework throughout your organization
A typical microservice may depend on multiple infrastructure components.
Order Service
│
├── Oracle
├── Kafka
├── Redis
├── Elasticsearch
└── User Service (HTTP)
When Kafka becomes unavailable:
Without core-go/health
✓ HTTP Server
/health -> 200 OK
Everything appears healthy.
With core-go/health
✓ Oracle
✓ Redis
✗ Kafka
✓ Elasticsearch
✓ User Service
/health -> DOWN
Your monitoring system immediately identifies the failed dependency, allowing engineers to investigate the correct component instead of spending hours searching for the root cause.
- Framework Independent — No dependency on Gin, Echo, or any other web framework.
- Provider Based — Every dependency is implemented as an independent provider.
- Extensible — Easily add custom providers.
- Production Ready — Designed for Kubernetes and cloud-native applications.
- Minimal API — Simple to learn and easy to integrate.
A healthy service is not simply one whose HTTP server is running.
A healthy service is one that can successfully communicate with all of its critical dependencies and continue serving requests.
- Purpose: Monitors the availability of external services.
- Features:
- Check HTTP/HTTPS endpoints for expected responses.
- http client. The sample is at go-sql-hexagonal-architecture-sample.
- Measure response time and reliability.
- Check HTTP/HTTPS endpoints for expected responses.
- Purpose: Verifies the status of cache services.
- Features:
- Check connectivity to cache servers (Redis, Memcached).
- Redis:
- go-redis/redis to support redis/go-redis. The sample is at go-admin.
- garyburd/redigo to support gomodule/redigo.
- Redis:
- Validate cache hit/miss ratio and performance metrics.
- Check connectivity to cache servers (Redis, Memcached).
- Purpose: Monitors the health of database connections
- Features:
- Check connectivity and response time for various databases (SQL, NoSQL).
- sql. The sample is at go-sql-sample.
- mongo to support mongo-driver/mongo. The sample is at go-mongo-sample.
- dynamodb to support aws/aws-sdk-go/service/dynamodb. The sample is at go-dynamodb-tutorial.
- firestore to support go/firestore. The sample is at go-firestore-sample.
- elasticsearch to support elastic/go-elasticsearch. The sample is at go-elasticsearch-sample.
- cassandra to support apache/cassandra-gocql-driver. The sample is at go-cassandra-sample.
- hive to support beltran/gohive. The sample is at go-hive-sample.
- Provide detailed status messages and error handling.
- Check connectivity and response time for various databases (SQL, NoSQL).
- Purpose: Ensures message queues are operational.
- Features:
- Check connectivity and queue depth for different message brokers.
- Amazon SQS: support aws-sdk-go/service/sqs. The sample is at go-amazon-sqs-sample.
- Google Pub/Sub: support go/pubsub. The sample is at go-pubsub-sample.
- Kafka: support 3 GO libraries: segmentio/kafka-go, IBM/sarama and confluent. The sample is at go-kafka-sample.
- NATS: support nats.go. The sample is at go-nats-sample.
- Active MQ: support go-stomp. The sample is at go-active-mq-sample.
- RabbitMQ: support rabbitmq/amqp091-go. The sample is at go-rabbit-mq-sample.
- IBM MQ: support ibmmq. The sample is at go-ibm-mq-sample.
- Check connectivity and queue depth for different message brokers.
MIT