watchtower-agent
v0.1.0
Published
Drop-in Express middleware that captures HTTP metrics and process stats, pushes to a central collector with Slack alerting.
Maintainers
Readme
watchtower-agent
Drop-in Express middleware that captures HTTP metrics and process stats, pushes to a central collector with Slack, Discord, and email alerting.
Built on prom-client. MIT licensed.
Install
npm install watchtower-agentQuick start
import { watchtower } from 'watchtower-agent';
app.use(watchtower({
serviceName: 'my-api',
collector: 'http://localhost:9090', // optional
}));What it captures
- HTTP request duration (histogram, p50/p95/p99)
- HTTP requests total (by method, route, status code)
- Node.js default metrics: CPU, memory, event loop lag, GC
Expose metrics endpoint (optional)
import { register } from 'watchtower-agent';
app.get('/metrics', async (req, res) => {
res.set('Content-Type', register.contentType);
res.send(await register.metrics());
});Configuration
| Option | Default | Description |
|---|---|---|
| serviceName | 'app' | Identifies this service in the collector |
| collector | undefined | URL of watchtower-collector. If omitted, metrics are only exposed locally |
Architecture
Your app (watchtower middleware)
└─ pushes Prometheus text every 15s
└─ watchtower-collector
├─ evaluates alert rules every 30s
├─ fires Slack webhook
├─ fires Discord webhook
└─ sends email via ResendPair with watchtower-collector
See watchtower-collector for the collector + alerting setup.
What this isn't
Not a replacement for Prometheus + Grafana in production. This is a focused agent + collector + alerting pipeline for teams that want observability without the setup overhead. For production scale, use OpenTelemetry.
License
MIT
