A simple Node.js application that monitors InfluxDB data recency and sends Telegram alerts when data becomes stale.
- ✅ Monitors multiple InfluxDB buckets for data recency
- 📱 Sends Telegram alerts when data is stale or missing
- 📊 Comprehensive logging with Winston
- 🐳 Docker support with multi-arch builds
- 🚀 GitHub Actions CI/CD pipeline
- ⚡ Modern ES modules and latest Node.js features
- Node.js 18+
- InfluxDB instance
- Telegram bot token and chat ID
- Clone the repository:
git clone <your-repo-url>
cd influxdb-monitor- Install dependencies:
npm install- Configure environment variables:
cp .env.example .env
# Edit .env with your configuration- Start the application:
npm start| Variable | Description | Required | Default |
|---|---|---|---|
INFLUXDB_URL |
InfluxDB server URL | ✅ | - |
INFLUXDB_TOKEN |
InfluxDB access token | ✅ | - |
INFLUXDB_ORG |
InfluxDB organization | ✅ | - |
BUCKETS_TO_MONITOR |
Comma-separated list of buckets | ✅ | - |
TOLERANCE |
Maximum age before alerting (e.g., "30s", "5m", "1h") | ✅ | 30s |
TELEGRAM_BOT_TOKEN |
Telegram bot token | ✅ | - |
TELEGRAM_CHAT_ID |
Telegram chat ID for alerts | ✅ | - |
CHECK_INTERVAL_MINUTES |
How often to check (minutes) | ❌ | 5 |
LOG_LEVEL |
Logging level (debug, info, warn, error) | ❌ | info |
- Create a bot by messaging @BotFather on Telegram
- Get your chat ID by messaging @userinfobot
- Add the bot to your chat/channel and make it an admin (if using a channel)
# Build the image
docker build -t influxdb-monitor .
# Run with environment file
docker run -d --name influxdb-monitor --env-file .env influxdb-monitor
# Or run with individual environment variables
docker run -d --name influxdb-monitor \
-e INFLUXDB_URL=https://your-influxdb.com \
-e INFLUXDB_TOKEN=your-token \
-e INFLUXDB_ORG=your-org \
-e BUCKETS_TO_MONITOR=bucket1,bucket2 \
-e TOLERANCE=30s \
-e TELEGRAM_BOT_TOKEN=your-bot-token \
-e TELEGRAM_CHAT_ID=your-chat-id \
influxdb-monitorversion: '3.8'
services:
influxdb-monitor:
build: .
env_file: .env
restart: unless-stopped
healthcheck:
test: ["CMD", "node", "-e", "console.log('Health check passed')"]
interval: 30s
timeout: 3s
retries: 3npm start # Start the application
npm run dev # Start with file watching
npm test # Run tests
npm run lint # Run ESLint
npm run format # Format code with Prettiersrc/
├── index.js # Main application entry point
├── influxdb-client.js # InfluxDB connection and queries
├── telegram-client.js # Telegram bot integration
├── logger.js # Winston logging configuration
└── utils.js # Utility functions
The project includes a complete CI/CD pipeline:
- Test: Runs on Node.js 18 and 20
- Security: Performs npm audit
- Build: Creates multi-arch Docker images
- Deploy: Placeholder for deployment logic
Images are automatically pushed to GitHub Container Registry (ghcr.io).
- 🚨 Stale Data: When data is older than the tolerance threshold
⚠️ No Data: When no data is found in a bucket- ❌ Error: When there's an error checking a bucket
debug: Detailed query informationinfo: General status updateswarn: Stale data warningserror: Connection and query errors
-
InfluxDB Connection Errors
- Verify URL, token, and organization
- Check network connectivity
- Ensure token has read permissions
-
Telegram Not Working
- Verify bot token and chat ID
- Ensure bot is added to the chat/channel
- Check bot permissions
-
No Data Found
- Verify bucket names are correct
- Check if data exists in the specified time range
- Review InfluxDB query logs
Enable debug logging:
LOG_LEVEL=debug npm startMIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request