Get Sentinel up and running in under 5 minutes.
1. Install Sentinel
Run the install script:
|
Add to your PATH if needed:
Verify it works:
2. Create a Configuration File
Create sentinel.kdl in your current directory:
system {
worker-threads 0
}
listeners {
listener "http" {
address "0.0.0.0:8080"
protocol "http"
}
}
routes {
route "api" {
matches {
path-prefix "/api/"
}
upstream "api-backend"
}
route "default" {
priority "low"
matches {
path-prefix "/"
}
upstream "web-backend"
}
}
upstreams {
upstream "api-backend" {
targets {
target { address "127.0.0.1:3000" }
}
}
upstream "web-backend" {
targets {
target { address "127.0.0.1:3001" }
}
}
}
observability {
metrics {
enabled #true
address "0.0.0.0:9090"
}
logging {
level "info"
format "json"
}
}
3. Start a Test Backend
For testing, start a simple backend server:
# Using Python (port 3000)
&
# Or using Node.js
&
4. Run Sentinel
You should see:
INFO sentinel starting up
INFO listener http listening on 0.0.0.0:8080
INFO metrics server listening on 0.0.0.0:9090
5. Test It
In a new terminal:
# Test the proxy
# Check metrics
What’s Happening
- Listener accepts HTTP connections on port 8080
- Router matches requests against route rules:
/api/*requests go toapi-backend(port 3000)- All other requests go to
web-backend(port 3001)
- Upstream forwards requests to your backend servers
- Metrics are exposed on port 9090 for monitoring
Add Health Checks
Update your config to add health checks:
upstreams {
upstream "api-backend" {
targets {
target { address "127.0.0.1:3000" }
}
health-check {
type "http" {
path "/health"
}
interval-secs 10
unhealthy-threshold 3
}
}
}
Reload the configuration:
# Send SIGHUP to reload
Add TLS
For HTTPS, generate certificates and update the config:
# Generate self-signed cert for testing
listeners {
listener "https" {
address "0.0.0.0:8443"
protocol "https"
tls {
cert-file "cert.pem"
key-file "key.pem"
}
}
}
Test with:
Next Steps
- Basic Configuration - Detailed configuration reference
- First Route - Deep dive into routing
- Service Types - Learn about API, web, and static modes
- Health Checks - Configure upstream monitoring