feat: enhance Ansible playbook and Nginx configuration with authentication and logrotate setup
- Added environment variables for project configuration in env.template. - Updated Ansible playbook to use environment variables for project settings and added tasks for monitoring authentication setup. - Enhanced Nginx configuration for Alertmanager and Prometheus with HTTP Basic Authentication. - Introduced logrotate configuration for managing log files and set up cron for daily execution. - Removed obsolete Uptime Kuma docker-compose file.
This commit is contained in:
77
infra/uptime-kuma/README.md
Normal file
77
infra/uptime-kuma/README.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# Uptime Kuma Configuration
|
||||
|
||||
Uptime Kuma - это статусная страница для мониторинга доступности сервисов.
|
||||
|
||||
## Доступ
|
||||
|
||||
- **Веб-интерфейс**: `https://your-domain/status/`
|
||||
- **Прямой доступ**: `http://localhost:3001` (только локально)
|
||||
|
||||
## Настройка
|
||||
|
||||
### Первоначальная настройка
|
||||
|
||||
1. Запустите сервисы:
|
||||
```bash
|
||||
make up
|
||||
```
|
||||
|
||||
2. Откройте `https://your-domain/status/`
|
||||
|
||||
3. Создайте администратора:
|
||||
- Username: `admin`
|
||||
- Password: `admin` (смените после первого входа)
|
||||
|
||||
### Мониторинг сервисов
|
||||
|
||||
Uptime Kuma автоматически настроит мониторинг следующих сервисов:
|
||||
|
||||
- **Telegram Bot**: `http://telegram-bot:8080/health`
|
||||
- **AnonBot**: `http://anon-bot:8081/health`
|
||||
- **Prometheus**: `http://prometheus:9090/-/healthy`
|
||||
- **Grafana**: `http://grafana:3000/api/health`
|
||||
- **AlertManager**: `http://alertmanager:9093/-/healthy`
|
||||
- **Nginx**: `http://nginx:80/nginx-health`
|
||||
|
||||
### Уведомления
|
||||
|
||||
Настройте уведомления в веб-интерфейсе:
|
||||
- Telegram Bot
|
||||
- Email
|
||||
- Webhook
|
||||
- Discord
|
||||
- Slack
|
||||
|
||||
## Файлы конфигурации
|
||||
|
||||
- `monitors.json` - экспорт настроенных мониторов
|
||||
- `settings.json` - настройки приложения
|
||||
- `backup/` - резервные копии конфигурации
|
||||
|
||||
## Команды управления
|
||||
|
||||
```bash
|
||||
# Показать логи
|
||||
make logs-uptime-kuma
|
||||
|
||||
# Перезапустить
|
||||
make restart-uptime-kuma
|
||||
|
||||
# Проверить статус
|
||||
make status
|
||||
```
|
||||
|
||||
## Резервное копирование
|
||||
|
||||
Конфигурация сохраняется в Docker volume `uptime_kuma_data`.
|
||||
Для резервного копирования:
|
||||
|
||||
```bash
|
||||
# Создать backup
|
||||
make backup
|
||||
|
||||
# Восстановить
|
||||
make restore FILE=backup.tar.gz
|
||||
```
|
||||
|
||||
|
||||
36
infra/uptime-kuma/backup/README.md
Normal file
36
infra/uptime-kuma/backup/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Uptime Kuma Backup
|
||||
|
||||
Эта директория содержит резервные копии конфигурации Uptime Kuma.
|
||||
|
||||
## Автоматическое резервное копирование
|
||||
|
||||
Создайте скрипт для автоматического бэкапа:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# backup-uptime-kuma.sh
|
||||
|
||||
DATE=$(date +%Y%m%d-%H%M%S)
|
||||
BACKUP_DIR="/path/to/backups"
|
||||
CONTAINER_NAME="bots_uptime_kuma"
|
||||
|
||||
# Создать backup
|
||||
docker exec $CONTAINER_NAME tar -czf /tmp/uptime-kuma-backup-$DATE.tar.gz /app/data
|
||||
|
||||
# Скопировать backup на хост
|
||||
docker cp $CONTAINER_NAME:/tmp/uptime-kuma-backup-$DATE.tar.gz $BACKUP_DIR/
|
||||
|
||||
# Очистить временные файлы
|
||||
docker exec $CONTAINER_NAME rm /tmp/uptime-kuma-backup-$DATE.tar.gz
|
||||
|
||||
echo "Backup created: $BACKUP_DIR/uptime-kuma-backup-$DATE.tar.gz"
|
||||
```
|
||||
|
||||
## Восстановление
|
||||
|
||||
```bash
|
||||
# Восстановить из backup
|
||||
docker cp backup-file.tar.gz $CONTAINER_NAME:/tmp/
|
||||
docker exec $CONTAINER_NAME tar -xzf /tmp/backup-file.tar.gz -C /
|
||||
docker restart $CONTAINER_NAME
|
||||
```
|
||||
@@ -1,33 +0,0 @@
|
||||
# Uptime Kuma Configuration
|
||||
# This is a separate docker-compose file for Uptime Kuma
|
||||
# It will be included in the main docker-compose.yml
|
||||
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
uptime-kuma:
|
||||
image: louislam/uptime-kuma:latest
|
||||
container_name: bots_uptime_kuma
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- uptime_kuma_data:/app/data
|
||||
ports:
|
||||
- "3001:3001"
|
||||
environment:
|
||||
- UPTIME_KUMA_PORT=3001
|
||||
networks:
|
||||
- bots_network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3001"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
uptime_kuma_data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
bots_network:
|
||||
external: true
|
||||
147
infra/uptime-kuma/monitors.json
Normal file
147
infra/uptime-kuma/monitors.json
Normal file
@@ -0,0 +1,147 @@
|
||||
{
|
||||
"monitors": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Telegram Bot Health",
|
||||
"url": "http://telegram-bot:8080/health",
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"interval": 60,
|
||||
"retries": 3,
|
||||
"timeout": 10,
|
||||
"keyword": null,
|
||||
"maxredirects": 10,
|
||||
"ignoreTls": false,
|
||||
"upsideDown": false,
|
||||
"tags": ["bot", "telegram", "health"],
|
||||
"description": "Мониторинг состояния Telegram Helper Bot",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "AnonBot Health",
|
||||
"url": "http://anon-bot:8081/health",
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"interval": 60,
|
||||
"retries": 3,
|
||||
"timeout": 10,
|
||||
"keyword": null,
|
||||
"maxredirects": 10,
|
||||
"ignoreTls": false,
|
||||
"upsideDown": false,
|
||||
"tags": ["bot", "anon", "health"],
|
||||
"description": "Мониторинг состояния AnonBot",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Prometheus Health",
|
||||
"url": "http://prometheus:9090/-/healthy",
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"interval": 60,
|
||||
"retries": 3,
|
||||
"timeout": 10,
|
||||
"keyword": null,
|
||||
"maxredirects": 10,
|
||||
"ignoreTls": false,
|
||||
"upsideDown": false,
|
||||
"tags": ["monitoring", "prometheus", "health"],
|
||||
"description": "Мониторинг состояния Prometheus",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Grafana Health",
|
||||
"url": "http://grafana:3000/api/health",
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"interval": 60,
|
||||
"retries": 3,
|
||||
"timeout": 10,
|
||||
"keyword": null,
|
||||
"maxredirects": 10,
|
||||
"ignoreTls": false,
|
||||
"upsideDown": false,
|
||||
"tags": ["monitoring", "grafana", "health"],
|
||||
"description": "Мониторинг состояния Grafana",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "AlertManager Health",
|
||||
"url": "http://alertmanager:9093/-/healthy",
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"interval": 60,
|
||||
"retries": 3,
|
||||
"timeout": 10,
|
||||
"keyword": null,
|
||||
"maxredirects": 10,
|
||||
"ignoreTls": false,
|
||||
"upsideDown": false,
|
||||
"tags": ["monitoring", "alertmanager", "health"],
|
||||
"description": "Мониторинг состояния AlertManager",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Nginx Health",
|
||||
"url": "http://nginx:80/nginx-health",
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"interval": 60,
|
||||
"retries": 3,
|
||||
"timeout": 10,
|
||||
"keyword": "healthy",
|
||||
"maxredirects": 10,
|
||||
"ignoreTls": false,
|
||||
"upsideDown": false,
|
||||
"tags": ["infrastructure", "nginx", "health"],
|
||||
"description": "Мониторинг состояния Nginx",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "External Bot Status",
|
||||
"url": "https://your-domain/status/",
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"interval": 300,
|
||||
"retries": 2,
|
||||
"timeout": 15,
|
||||
"keyword": null,
|
||||
"maxredirects": 10,
|
||||
"ignoreTls": false,
|
||||
"upsideDown": false,
|
||||
"tags": ["external", "status-page"],
|
||||
"description": "Мониторинг внешней доступности статусной страницы",
|
||||
"active": false
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "bot",
|
||||
"color": "#3498db"
|
||||
},
|
||||
{
|
||||
"name": "monitoring",
|
||||
"color": "#e74c3c"
|
||||
},
|
||||
{
|
||||
"name": "infrastructure",
|
||||
"color": "#f39c12"
|
||||
},
|
||||
{
|
||||
"name": "health",
|
||||
"color": "#27ae60"
|
||||
},
|
||||
{
|
||||
"name": "external",
|
||||
"color": "#9b59b6"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
24
infra/uptime-kuma/settings.json
Normal file
24
infra/uptime-kuma/settings.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"language": "ru",
|
||||
"theme": "light",
|
||||
"timezone": "Europe/Moscow",
|
||||
"dateLocale": "ru",
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"timeFormat": "24",
|
||||
"weekStart": 1,
|
||||
"searchEngineIndex": true,
|
||||
"primaryBaseURL": "https://your-domain/status/",
|
||||
"public": true,
|
||||
"publicGroupList": true,
|
||||
"showTags": true,
|
||||
"showPoweredBy": false,
|
||||
"keepDataPeriodDays": 365,
|
||||
"retentionCheckInterval": 3600,
|
||||
"maxmindLicenseKey": "",
|
||||
"dnsCache": true,
|
||||
"dnsCacheTtl": 300,
|
||||
"trustProxy": true,
|
||||
"disableAuth": false,
|
||||
"defaultTimezone": "Europe/Moscow",
|
||||
"defaultLanguage": "ru"
|
||||
}
|
||||
Reference in New Issue
Block a user