One endpoint, four checks
Myaku Health Check exposes a single GET /health endpoint that reports the state
of your disk, RAM, database, and cache. Database and cache are auto-detected, no extra config.
x-myaku-token header. Two independent guards evaluated in order.doctrine.dbal.default_connection and cache.app are wired automatically when available. Absent services are skipped.503.Dependencies
| Package | Version | Role |
|---|---|---|
| php | ≥ 8.2 | Required by Symfony 7.4+ |
| symfony/http-kernel | ^7.4 · ^8.0 | AbstractBundle, Request handling |
| symfony/console | ^7.4 · ^8.0 | Dependency injection |
| doctrine/dbal | ^3.0 · ^4.0 | Database connectivity check |
| symfony/cache-contracts | ^3.0 | Cache interface (optional) |
doctrine/doctrine-bundle and symfony/cache are auto-wired when present
their checks are simply skipped when absent.
Setup
01 — Require
02 — Register the bundle
// config/bundles.php
return [
Devexploris\MyakuHealthCheck\MyakuHealthCheckBundle::class => ['all' => true],
];
03 — Register the route
# config/routes.yaml
myaku_health_check:
resource: Devexploris\MyakuHealthCheck\Controller\HealthCheckController
type: attribute
Configuration
Create config/packages/myaku_health_check.yaml:
myaku_health_check:
threshold: # optional
space: 80 # alert if disk usage exceeds X% (0–100)
memory: 90 # alert if RAM usage exceeds X% (0–100)
space:
path: / # mount point to monitor (default: /)
security:
token: "%env(APP_MYAKU_TOKEN)%" # generate with: openssl rand -hex 24
whitelist: # optional if empty, all IPs are allowed
- "127.0.0.1"
- "172.21.0.1"
Thresholds
Both thresholds are optional. When configured, a usage percentage above the threshold triggers a 503 response and sets threshold_targeted: true in the JSON payload.
| Key | Type | Description |
|---|---|---|
threshold.space | int (0–100) | Disk usage alert threshold (%) |
threshold.memory | int (0–100) | RAM usage alert threshold (%)for Linux only |
space.path | string | Mount point to monitor (default: /) |
Security keys
| Key | Description |
|---|---|
security.token | Bearer token required in the x-myaku-token header |
security.whitelist | List of allowed client IPs. If empty, all IPs are accepted |
GET /health
Single entry point for all health checks. Returns 200 when everything is healthy, 503 when at least one check fails or exceeds its threshold.
| Code | Meaning |
|---|---|
200 |
All checks are healthy |
403 |
IP not allowed or invalid token |
503 |
At least one check failed or exceeded its threshold |
Two guards, one order
Two controls are applied sequentially. The first failure immediately returns 403, the second guard is never evaluated.
| 01 | IP whitelist if the list is not empty, the client IP must be present. Otherwise 403. An empty whitelist allows all IPs. |
| 02 | Token the x-myaku-token header must match the configured token. Otherwise 403. |
curl -H "x-myaku-token: your_token_here" https://your-app.com/health
JSON payload
Healthy response
The fields threshold and threshold_targeted only appear when the corresponding threshold is configured.
{
"space": {
"free": "45.30 Go",
"used": "54.70 Go",
"total": "100.00 Go",
"threshold": "80%",
"threshold_targeted": false
},
"memory": {
"free": "4.77 Go",
"used": "10.04 Go",
"total": "14.81 Go",
"threshold": "90%",
"threshold_targeted": false
},
"database": {
"connected": true,
"latency": "1.23ms"
},
"cache": {
"connected": true,
"latency": "0.45ms"
}
}
threshold_targeted: true
the usage percentage exceeds the configured threshold. This alone triggers a 503.
Error responses
When a service is unreachable, connected is false and an error field contains the exception message. The overall response becomes 503.
Database
{
"database": {
"connected": false,
"error": "SQLSTATE[HY000] [2002] Connection refused"
}
}
Cache
{
"cache": {
"connected": false,
"error": "No cache configured"
}
}
Platform support
| Check | Linux | macOS | Windows |
|---|---|---|---|
| Disk space | ✅ | ✅ | ✅ |
| RAM | ✅ | ❌ | ❌ |
| Database | ✅ | ✅ | ✅ |
| Cache | ✅ | ✅ | ✅ |
MemoryChecker reads /proc/meminfo, which is only available on Linux.
On other systems, the memory check is silently skipped.