An API for gathering Linux server / Docker Engine metrics.
This will be used in coolify.io.
docker run -d \
-p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
-e TOKEN=your-secret-token \
-e PUSH_ENDPOINT=https://your-endpoint.com/metrics \
ghcr.io/coollabsio/sentinel:latest
# Clone the repository
git clone https://github.com/coollabsio/sentinel.git
cd sentinel
# Install dependencies
go mod download
# Run the application
TOKEN=your-secret-token go run main.go
# Install Air if not already installed
go install github.com/cosmtrek/air@latest
# Run with hot reload
air
Sentinel is configured using environment variables:
| Variable | Description | Example |
|---|---|---|
TOKEN |
Authentication token for API access | your-secret-token |
| Variable | Default | Description |
|---|---|---|
PUSH_ENDPOINT |
- | URL to push metrics to |
PUSH_INTERVAL_SECONDS |
60 | Interval for pushing metrics |
COLLECTOR_ENABLED |
true |
Enable/disable metrics collection |
COLLECTOR_REFRESH_RATE_SECONDS |
10 | Metrics collection interval |
COLLECTOR_RETENTION_PERIOD_DAYS |
7 | How long to keep metrics in database |
DEBUG |
false |
Enable debug mode and profiling endpoints |
PORT |
8080 |
HTTP server port |
export TOKEN=your-secret-token
export PUSH_ENDPOINT=https://coolify.io/api/metrics
export COLLECTOR_REFRESH_RATE_SECONDS=30
export COLLECTOR_RETENTION_PERIOD_DAYS=14
export DEBUG=false
./sentinel
Sentinel provides a comprehensive REST API for retrieving system and Docker container metrics.
GET /api/health - Health checkGET /api/version - Get service versionGET /api/cpu/current - Current CPU usageGET /api/cpu/history - Historical CPU dataGET /api/memory/current - Current memory usageGET /api/memory/history - Historical memory dataGET /api/container/:id/cpu/history - Container CPU historyGET /api/container/:id/memory/history - Container memory historyAll API requests require a Bearer token:
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8080/api/cpu/current
For detailed API documentation including request/response examples, query parameters, and error responses, see API.md.
An OpenAPI 3.0 specification is available at openapi.yaml for use with Swagger UI and other API tools.
Sentinel follows a service-oriented architecture with these components:
pkg/api/) - Gin-based HTTP server exposing metrics endpointspkg/collector/) - Periodically collects system and Docker metricspkg/push/) - Sends metrics to external endpointspkg/db/) - SQLite storage with automatic cleanupDocker Engine ──┐
├──> Collector Service ──> SQLite Database ──> API Server ──> Clients
System Stats ───┘ │
└──> Push Service ──> External Endpoint
sentinel/
├── cmd/ # Application entry points
├── pkg/
│ ├── api/ # HTTP API and controllers
│ ├── collector/ # Metrics collection service
│ ├── push/ # Push service
│ ├── db/ # Database layer
│ └── config/ # Configuration management
├── main.go # Application main
├── go.mod # Go dependencies
├── Dockerfile # Docker build configuration
├── API.md # API documentation
└── openapi.yaml # OpenAPI specification
# Build binary
go build -o sentinel .
# Build Docker image
docker build -t sentinel .
# Run tests
go test ./...
# Format code
go fmt ./...
# Run linter
golangci-lint run
Key dependencies used in the project:
version: '3.8'
services:
sentinel:
image: ghcr.io/coollabsio/sentinel:latest
ports:
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- sentinel-data:/data
environment:
TOKEN: ${SENTINEL_TOKEN}
PUSH_ENDPOINT: ${PUSH_ENDPOINT}
COLLECTOR_REFRESH_RATE_SECONDS: 30
COLLECTOR_RETENTION_PERIOD_DAYS: 14
restart: unless-stopped
volumes:
sentinel-data:
[Unit]
Description=Sentinel Metrics Service
After=network.target docker.service
Requires=docker.service
[Service]
Type=simple
User=sentinel
Environment="TOKEN=your-secret-token"
Environment="PUSH_ENDPOINT=https://your-endpoint.com/metrics"
ExecStart=/usr/local/bin/sentinel
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
curl http://localhost:8080/api/health
When DEBUG=true, access database statistics:
curl -H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8080/api/stats
Go profiling endpoints are available at /debug/pprof/* when debug mode is enabled.
This is an experimental project for Coolify.io. Contributions are welcome!
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)See LICENSE file for details.
For issues and questions: - GitHub Issues: https://github.com/coollabsio/sentinel/issues - Coolify Discord: https://discord.gg/coolify
$ claude mcp add sentinel \
-- python -m otcore.mcp_server <graph>