Self-hosted server & database monitoring with live dashboard and alerts. Single small container.
202
Self-hosted monitoring for your servers and databases, in one small container.
Clearwatch is a small monitoring tool that you run yourself. You start one container and it:
http://your-server:8080/.It is one program with no database to install, no agent to roll out and no cloud account. It uses about 19 MB of RAM and well under 1 % of a CPU core.
| Clearwatch fits if you... | Look elsewhere if you... |
|---|---|
| run one or a few servers or VMs and want to know when something breaks | need to monitor hundreds of machines from one place |
| want a dashboard and alerts in five minutes, not a weekend | need months of history (Clearwatch keeps 24 h by default) |
| want to watch a PostgreSQL or MySQL database's health | need to monitor the contents of your data (business metrics) |
| prefer a tiny tool you can read and trust | need Windows or ARM hosts (linux/amd64 only for now) |
/proc, /sys ──┐
PostgreSQL ───┼─> collectors ─> SQLite file (24 h) ─> dashboard, JSON API, Prometheus
MySQL ────────┘ │
└──────> alert engine ──> Telegram / Slack / Discord / webhook
/proc and /sys (you mount them into the container, read-only)
every 10 s, and ask each database for its statistics every 30 s./data. Old data is deleted automatically.You need a Linux server with Docker installed.
docker run -d --name clearwatch --restart unless-stopped \
-p 127.0.0.1:8080:8080 \
-v clearwatch-data:/data \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-e CLEARWATCH_INSTANCE_NAME=my-server \
ritejmule2610/clearwatch:latest
127.0.0.1: keeps the dashboard private to the server itself until you add a password (step 3).
CLEARWATCH_INSTANCE_NAME is the name shown on the dashboard and in alerts.
docker ps # status should say "healthy" after ~30 s
curl http://127.0.0.1:8080/healthz # prints OK
docker exec clearwatch /clearwatch version
Open http://127.0.0.1:8080/. Charts start filling after one or two collection intervals (about
20 s). On a remote server, reach it from your laptop with ssh -L 8080:127.0.0.1:8080 user@server,
then open http://localhost:8080/.
Remove the container (docker rm -f clearwatch; your data stays in the volume) and start it again
with a login and an API key added:
docker run -d --name clearwatch --restart unless-stopped \
-p 127.0.0.1:8080:8080 \
-v clearwatch-data:/data -v /proc:/host/proc:ro -v /sys:/host/sys:ro \
-e CLEARWATCH_INSTANCE_NAME=my-server \
-e CLEARWATCH_AUTH_USER=admin \
-e CLEARWATCH_AUTH_PASS='use-a-long-password' \
-e CLEARWATCH_API_KEY="$(openssl rand -hex 24)" \
ritejmule2610/clearwatch:latest
The dashboard now asks for the username and password. Scripts can use
curl -H "Authorization: Bearer <key>". /healthz stays open so Docker and load balancers can
still check it. To make it reachable from other machines, put a TLS reverse proxy (Caddy or nginx)
in front of port 8080. Do not publish a password-protected port over plain HTTP.
Add one or more of these -e options to the docker run command, then recreate the container:
-e CLEARWATCH_TELEGRAM_BOT_TOKEN='123456:ABC...' -e CLEARWATCH_TELEGRAM_CHAT_ID='-1001234567890'
-e CLEARWATCH_WEBHOOK_URL='https://hooks.slack.com/services/T000/B000/XXXX'
Then send a test message to every channel you configured:
docker exec clearwatch /clearwatch test-alert
If the message arrives, alerts work. Default thresholds: CPU 90 %, memory 90 %, disk 85 %.
Create a read-only user for Clearwatch, then pass its connection string.
PostgreSQL 10+
CREATE ROLE clearwatch LOGIN PASSWORD 'a-long-random-password';
GRANT pg_monitor TO clearwatch; -- statistics only, no table data
GRANT CONNECT ON DATABASE app TO clearwatch;
ALTER ROLE clearwatch SET default_transaction_read_only = on;
-- optional, for "Top queries" (also needs shared_preload_libraries = 'pg_stat_statements'):
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
-e CLEARWATCH_POSTGRES_DSN='postgres://clearwatch:[email protected]:5432/app?sslmode=require'
MySQL 5.7 / 8.x
CREATE USER 'clearwatch'@'10.0.0.%' IDENTIFIED BY 'a-long-random-password' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'clearwatch'@'10.0.0.%';
GRANT SELECT ON performance_schema.* TO 'clearwatch'@'10.0.0.%'; -- Top queries
GRANT SELECT ON app.* TO 'clearwatch'@'10.0.0.%'; -- table sizes only
-e CLEARWATCH_MYSQL_DSN='mysql://clearwatch:[email protected]:3306/app'
The dashboard gains a database card within one interval (30 s). Notes:
localhost means the container itself. Put Clearwatch on the database's Docker
network, or use the database's hostname or host.docker.internal.CLEARWATCH_CONFIG).services:
clearwatch:
image: ritejmule2610/clearwatch:latest
restart: unless-stopped
ports: ["127.0.0.1:8080:8080"]
volumes:
- clearwatch-data:/data
- /proc:/host/proc:ro
- /sys:/host/sys:ro
environment:
CLEARWATCH_INSTANCE_NAME: my-server
CLEARWATCH_AUTH_USER: admin
CLEARWATCH_AUTH_PASS: change-me-please
cap_drop: [ALL]
security_opt: ["no-new-privileges:true"]
volumes:
clearwatch-data:
| Rule | Default | Fires when |
|---|---|---|
| High CPU usage | 90 % | total CPU is at or above the threshold |
| High memory usage | 90 % | RAM used (excluding reclaimable cache) |
| Disk almost full | 85 % | any monitored filesystem |
| Database connections near the limit | 80 % | connections / max_connections |
| Database replication lag | 30 s | a replica falls behind |
| Database unreachable | on | a database cannot be reached |
Everything has a default. Set options with -e NAME=value; a YAML file is optional.
| Variable | Default | Meaning |
|---|---|---|
CLEARWATCH_INSTANCE_NAME | host name | Name shown in the dashboard and alerts. Set it: in Docker the host name is the container ID |
CLEARWATCH_INTERVAL | 10s | Host collection interval |
CLEARWATCH_RETENTION_RAW | 24h | How long samples are kept |
CLEARWATCH_AUTH_USER / _PASS | unset | HTTP Basic auth (password 8+ characters) |
CLEARWATCH_API_KEY | unset | Bearer key for scripts (16+ characters) |
CLEARWATCH_POSTGRES_DSN / CLEARWATCH_MYSQL_DSN | unset | Database to monitor (one per engine; more in YAML) |
CLEARWATCH_DB_INTERVAL | 30s | Database collection interval |
CLEARWATCH_TELEGRAM_BOT_TOKEN / _CHAT_ID | unset | Telegram alerts |
CLEARWATCH_WEBHOOK_URL | unset | JSON webhook (Slack, Discord, custom) |
CLEARWATCH_ALERT_CPU_PERCENT, _MEMORY_PERCENT, _DISK_PERCENT | 90, 90, 85 | Thresholds (0 disables a rule) |
CLEARWATCH_ALERT_DURATION / _COOLDOWN | 3m / 30m | How long a problem must last before alerting / repeat interval |
CLEARWATCH_COLLECTOR_<NAME>_ENABLED | true | Turn one collector off, e.g. NETWORK |
CLEARWATCH_DISK_PATHS | /data | Filesystems to monitor |
| Endpoint | Description |
|---|---|
GET / | Dashboard |
GET /healthz | Health check (always public) |
GET /metrics | Clearwatch's own health, Prometheus format |
GET /api/v1/latest | Newest value of every series |
GET /api/v1/query?name=…&range=1h | Time series (from/to, step, label.<key>=…) |
GET /api/v1/alerts | Pending and firing alerts |
GET /api/v1/collectors | Status and last error of each collector |
| Symptom | Likely cause and fix |
|---|---|
| Charts stay empty | Wait 20-30 s. Check docker logs clearwatch and /api/v1/collectors |
Container shows unhealthy | docker logs clearwatch. Usually /data is not writable (see below) |
| Database card says Down | Wrong host (localhost inside a container), wrong password, or no network route. The reason is shown on the card |
| No "Top queries" on PostgreSQL | pg_stat_statements is not loaded (shared_preload_libraries) |
| Test alert does not arrive | Check the token, chat ID or URL. docker logs clearwatch shows the delivery error with secrets removed |
| Host numbers look like a container's | /proc and /sys are not mounted. Add the two -v options from step 1 |
127.0.0.1: prefix, before exposing the port. Use TLS in front./proc and /sys read-only.Measured with default settings on a small VM:
| Download (compressed) | 6.4 MB |
| On disk (unpacked) | about 16 MB |
| Program | 13 MB static binary on a distroless base |
| Memory | about 19 MB RSS |
| CPU | about 0.6 % of one core |
| Data | about 26 bytes per sample, roughly 13 MB per day for a typical host |
/proc and /sys mounted into the container. Network shows
the container's own interface; use --network host to see the host's network cards./data by default. To see every host filesystem add
-v /:/host/root:ro -e CLEARWATCH_DISK_PATHS= -e CLEARWATCH_DISK_HOST_ROOT=/host/root./data, make it writable by uid 65532 (chown 65532 /your/dir).count(*).linux/amd64. History is the raw retention window (24 h by default); long-term
rollups are not included yet.| Tag | Meaning |
|---|---|
latest | Newest build of the main branch |
sha-<commit> | One exact build. Pin to one of these for repeatable deployments |
Every build is tested in CI before it is published: unit tests with the race detector, lint, integration tests against real PostgreSQL 16 and MySQL 8.0, and a smoke test of the final image (healthy, all collectors running, authentication enforced, databases reporting).
docker pull ritejmule2610/clearwatch:latest