grpchealth
A simple gRPC health check tool for testing and monitoring gRPC services.
Overview
grpchealth provides both server and client implementations of the gRPC Health Checking Protocol. It allows you to quickly spin up a health check server for testing or verify the health status of existing gRPC services.
Features
Installation
go install github.com/fujiwara/grpchealth/cmd/grpchealth@latest
Or build from source:
git clone https://github.com/fujiwara/grpchealth.git
cd grpchealth
make
Usage
Usage: grpchealth <command>
Flags:
-h, --help Show context-sensitive help.
Commands:
server <address> [flags]
Run gRPC health check server
client <address> [flags]
Run gRPC health check client
Run "grpchealth <command> --help" for more information on a command.
Server Mode
Start a basic gRPC health check server:
grpchealth server localhost:50051
Start a server with TLS:
grpchealth server localhost:50051 --cert-file server.crt --key-file server.key
Server Options
Usage: grpchealth server <address> [flags]
Run gRPC health check server
Arguments:
<address> gRPC server address
Flags:
-h, --help Show context-sensitive help.
-c, --cert-file=STRING Path to the server certificate file
-k, --key-file=STRING Path to the server key file
Client Mode
Check health of a gRPC service:
grpchealth client localhost:50051
Check with TLS:
grpchealth client localhost:50051 --tls
Check with TLS (skip certificate verification):
grpchealth client localhost:50051 --tls --insecure
Check specific service health:
grpchealth client localhost:50051 --service myservice
Client Options
Usage: grpchealth client <address> [flags]
Run gRPC health check client
Arguments:
<address> gRPC client address
Flags:
-h, --help Show context-sensitive help.
-t, --tls Use TLS for connection
-k, --insecure Use insecure connection
-s, --service="" Service name to check health status
Examples
Testing with a local server
- Start the health check server:
grpchealth server :50051
- In another terminal, check its health:
grpchealth client localhost:50051
Testing with TLS
- Generate self-signed certificates (for testing):
openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodes
- Start server with TLS:
grpchealth server :50051 --cert-file server.crt --key-file server.key
- Check health with TLS:
grpchealth client localhost:50051 --tls --insecure
Testing with Unix Domain Socket
- Start server with Unix Domain Socket:
grpchealth server unix:/tmp/grpc.sock
- In another terminal, check its health:
grpchealth client unix:/tmp/grpc.sock
Alternatively, you can use absolute paths directly:
grpchealth server /tmp/grpc.sock
grpchealth client /tmp/grpc.sock
Development
Building
make
Running tests
make test
Installing locally
make install
Creating distribution packages
make dist
License
See LICENSE file for details.
Author
Fujiwara Shunichiro