πΊπΈ English | π·πΊ Russian Version
Real-time Nginx log monitoring with instant Telegram notifications for 5xx server errors. Simple, effective, and ready to use.
- π Real-time monitoring -
tail -fstyle log parsing - π± Smart Telegram alerts - Instant notifications for 5xx errors with cooldown protection
- π³ Docker-ready - Full containerization with docker-compose
- βοΈ Simple configuration - Environment variables based setup
- π Zero setup - Works out of the box
- Docker & Docker Compose
- Telegram Bot Token (get from @BotFather)
- Telegram Chat ID (get from @userinfobot)
# 1. Clone and setup
git clone https://github.com/DanLinX2004X/nginx-log-monitor.git
cd nginx-log-monitor
# 2. Configure environment
cp .env.example .env
# Edit .env and add your Telegram token and chat ID
# 3. Launch everything
docker-compose up -d --build
# 4. View monitor logs
docker-compose logs -f monitor# Generate test traffic
curl http://localhost:8080/ # 200 Success
curl http://localhost:8080/nonexistent-page # 404 Client Error
# For 5xx testing, you can:
# - Modify Nginx config to return 500 errors
# - Or use the included test endpoint (if available)- nginx - Nginx web server with test page
- monitor - Python service that monitors logs and sends Telegram alerts
./logs:/var/log/nginx- Nginx writes logs here./logs:/app/logs- Monitor reads the same logs (read-only)
Configure in .env file:
TELEGRAM_TOKEN=your_bot_token_here
CHAT_ID=your_chat_id_here
# Optional: LOG_FILE=/app/logs/access.log# Stop and remove containers
docker-compose down
# Stop but keep data
docker-compose stop
# Restart services
docker-compose restart
# View specific service logs
docker-compose logs -f nginx
docker-compose logs -f monitor- Nginx serves web content and writes access logs to
./logs/access.log - Monitor reads logs in real-time using
tail -fapproach - When 5xx error occurs - sends formatted alert to Telegram
- Cooldown protection - prevents spam for repeated errors
π¨ 5xx ERROR
Time: 04/Oct/2025:21:30:00 +0000
IP: 127.0.0.1
Status: 500
Request: GET /api/users
This project features a robust CI/CD pipeline powered by GitHub Actions, automating both testing and deployment.
- Dependency Setup β Installs project requirements and updates pip
- Syntax Validation β Runs py_compile to ensure the code is clean
- Docker Build Test β Validates that the Docker image can be built successfully
- Compose Check β Verifies the correctness of the docker-compose.yml
- Security Scanning β Basic checks for exposed secrets and vulnerabilities
- Docker Hub Deployment β Automatically builds and publishes the image to Docker Hub
- Continuous Integration: On every push or pull request to
mainanddevelopbranches - Continuous Deployment: Automatic Docker image publishing on pushes to
mainbranch - Manual execution: Available via GitHub Actions UI
- Fast feedback: Immediate validation of code changes
The application is automatically published to Docker Hub and available as:
docker pull danlinx2004x/nginx-log-monitor:latest# Check if tokens are loaded
docker-compose logs monitor | grep "Telegram"
# Verify .env file
cat .env
# Test Telegram connection
docker exec nginx-monitor python -c "
import os; from dotenv import load_dotenv; load_dotenv()
print('Token:', bool(os.getenv('TELEGRAM_TOKEN')))
print('Chat ID:', bool(os.getenv('CHAT_ID')))
"# Check if Nginx is writing logs
docker-compose logs nginx
ls -la logs/
# Verify monitor can see the log file
docker exec nginx-monitor ls -la /app/logs/
# Test Nginx is responding
curl -I http://localhost:8080/# Restart monitor only
docker-compose restart monitor
# Rebuild and restart
docker-compose up -d --build monitornginx-log-monitor/
βββ docker-compose.yml # Multi-service setup
βββ Dockerfile # Monitor container
βββ parser.py # Main monitoring script
βββ requirements.txt # Python dependencies
βββ .env.example # Configuration template
βββ html/ # Web content
β βββ index.html # Test page
βββ .github # GitHub Actions CI/CD pipelines
β βββ /workflows/
| βββ ci.yml # Main CI pipeline configuration
|ββlogs/ # Nginx logs (auto-created)
βββ .gitattributes # Repository metadata
Contributions welcome! Feel free to:
- Open issues for bugs or feature requests
- Submit pull requests with improvements
- Star the repo if you find it useful
Simple, effective monitoring without the complexity.