Add Netdata compose

This commit is contained in:
2025-11-26 19:32:06 +00:00
parent e7305f5d4f
commit ac66c130be
2 changed files with 162 additions and 0 deletions
+124
View File
@@ -0,0 +1,124 @@
# Netdata - Docker Host Monitoring
Comprehensive real-time monitoring for Docker host and containers with alerting capabilities.
## Features
- **Container Monitoring**: Auto-detects and monitors all Docker containers
- CPU, memory, network, disk I/O per container
- Container state monitoring (running, stopped, unhealthy)
- Pre-configured alerts for resource usage
- **Host Monitoring**: Full system metrics
- CPU, memory, disk, network usage
- Process monitoring
- System health checks
- **Built-in Alerts**: Pre-configured alarms for:
- Container CPU and memory usage
- Container health status
- System resource exhaustion
- Disk space usage
## Access
Once deployed, access Netdata at: `http://your-host-ip:19999`
## Webhook Notifications Setup
Netdata supports Discord, Slack, and many other notification methods.
### Option 1: Via Web UI (Recommended)
1. Access Netdata at `http://your-host-ip:19999`
2. Click on "Alert Notifications" in the left sidebar
3. Select your notification service (Discord, Slack, etc.)
4. Enter your webhook URL
5. Test and save
### Option 2: Configuration File
Create a custom alert configuration by editing the health_alarm_notify.conf file:
1. After starting the container, exec into it:
```bash
docker exec -it netdata bash
```
2. Edit the notification config:
```bash
cd /etc/netdata
./edit-config health_alarm_notify.conf
```
#### For Discord:
```conf
SEND_DISCORD="YES"
DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
DEFAULT_RECIPIENT_DISCORD="alarms"
```
#### For Slack:
```conf
SEND_SLACK="YES"
SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
DEFAULT_RECIPIENT_SLACK="alarms"
```
#### For Generic Webhook:
```conf
SEND_CUSTOM="YES"
CUSTOM_SENDER="${status}"
DEFAULT_RECIPIENT_CUSTOM="alarms"
```
3. Test the notification:
```bash
/usr/libexec/netdata/plugins.d/alarm-notify.sh test
```
4. Restart the container to apply changes:
```bash
docker restart netdata
```
### Getting Webhook URLs
**Discord:**
1. Go to Server Settings → Integrations → Webhooks
2. Click "New Webhook"
3. Copy the webhook URL
**Slack:**
1. Go to https://api.slack.com/apps
2. Create a new app or select existing
3. Go to "Incoming Webhooks"
4. Add webhook to workspace
5. Copy the webhook URL
## Alert Configuration
Netdata comes with sensible defaults, but you can customize:
- **Alert thresholds**: Edit individual alarm files in `/etc/netdata/health.d/`
- **Notification frequency**: Configure repeat intervals in `health_alarm_notify.conf`
- **Alert filtering**: Set up role-based notifications
## Monitoring Capabilities
- Real-time metrics with 1-second granularity
- Automatic anomaly detection
- Zero-configuration auto-detection of containers
- Historical data retention
- Beautiful web dashboard with interactive charts
## Resources
- Official docs: https://learn.netdata.cloud/
- Alert configuration: https://learn.netdata.cloud/docs/alerting/
- Notification setup: https://learn.netdata.cloud/docs/alerting/notifications/
## Notes
- The container requires privileged access and specific capabilities to monitor the host system
- Docker socket is mounted read-only for security
- Data persists across container restarts via Docker volumes
+38
View File
@@ -0,0 +1,38 @@
version: '3'
services:
netdata:
container_name: netdata
image: netdata/netdata:latest
restart: unless-stopped
hostname: ${HOSTNAME:-docker-host}
ports:
- 19999:19999
cap_add:
- SYS_PTRACE
- SYS_ADMIN
security_opt:
- apparmor:unconfined
environment:
- TZ=${TZ}
- DOCKER_HOST=/var/run/docker.sock
volumes:
# Docker socket for container monitoring
- /var/run/docker.sock:/var/run/docker.sock:ro
# Host system monitoring
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /etc/os-release:/host/etc/os-release:ro
- /etc/passwd:/host/etc/passwd:ro
- /etc/group:/host/etc/group:ro
# Netdata config and data persistence
- netdata-config:/etc/netdata
- netdata-lib:/var/lib/netdata
- netdata-cache:/var/cache/netdata
volumes:
netdata-config:
netdata-lib:
netdata-cache: