A Prometheus exporter for monitoring IMAP mailbox quota usage across multiple accounts.
- 📊 Monitor multiple IMAP accounts from a single exporter
- 📈 Export quota usage, limits, and connection status as Prometheus metrics
- ⚙️ Configurable check intervals
- 🔒 Support for SSL/TLS IMAP connections
- 🐳 Lightweight Docker container
- 📝 Simple YAML configuration
| Metric | Type | Description | Labels |
|---|---|---|---|
imap_quota_used_kb |
Gauge | IMAP quota used in kilobytes | account |
imap_quota_limit_kb |
Gauge | IMAP quota limit in kilobytes | account |
imap_up |
Gauge | IMAP connection status (1=up, 0=down) | account |
# Pull the image
docker pull ghcr.io/jasminemoeller/imap-exporter:latest
# Create a config file
cat > config.yml << EOF
check_interval: 900 # Check every 15 minutes
accounts:
- name: personal
server: imap.example.com
port: 993
username: user@example.com
password: your-password
EOF
# Run the exporter
docker run -d \
--name imap-exporter \
-p 9226:9226 \
-v $(pwd)/config.yml:/app/config.yml:ro \
ghcr.io/jasminemoeller/imap-exporter:latestservices:
imap_exporter:
image: ghcr.io/jasminemoeller/imap-exporter:latest
restart: unless-stopped
ports:
- "9226:9226"
volumes:
- ./config.yml:/app/config.yml:roThen run:
docker-compose up -dCreate a config.yml file:
# Check interval in seconds (default: 900 = 15 minutes)
check_interval: 900
accounts:
# First account
- name: personal
server: imap.ionos.de
port: 993
username: personal@example.com
password: your-password
# Second account
- name: work
server: imap.gmail.com
port: 993
username: work@gmail.com
password: app-specific-password
# Add as many accounts as needed
- name: another-account
server: mail.example.com
port: 993
username: user@example.com
password: password123| Option | Required | Default | Description |
|---|---|---|---|
check_interval |
No | 900 | Interval between IMAP checks in seconds |
accounts[].name |
Yes | - | Unique identifier for the account (used as Prometheus label) |
accounts[].server |
Yes | - | IMAP server hostname |
accounts[].port |
No | 993 | IMAP port (typically 993 for SSL/TLS) |
accounts[].username |
Yes | - | IMAP username/email |
accounts[].password |
Yes | - | IMAP password |
You can specify a custom config file location:
docker run -d \
-v /path/to/my-config.yml:/etc/imap/config.yml:ro \
-p 9226:9226 \
ghcr.io/jasminemoeller/imap-exporter:latest \
--config /etc/imap/config.ymlAdd this to your prometheus.yml:
scrape_configs:
- job_name: 'imap-exporter'
scrape_interval: 5m
static_configs:
- targets: ['localhost:9226'](imap_quota_used_kb / imap_quota_limit_kb) * 100
imap_quota_used_kb / 1024 / 1024
(imap_quota_limit_kb - imap_quota_used_kb) / 1024 / 1024
(imap_quota_used_kb / imap_quota_limit_kb) > 0.8
imap_up
Example Grafana panel configurations:
- Query:
(imap_quota_used_kb{account="personal"} / imap_quota_limit_kb{account="personal"}) * 100 - Visualization: Gauge
- Unit: Percent (0-100)
- Thresholds:
- Green: 0-70
- Yellow: 70-85
- Red: 85-100
- Query:
imap_quota_used_kb / 1024 / 1024 - Visualization: Time series
- Unit: GB
- Legend:
{{account}}
- Set proper file permissions:
chmod 600 config.yml - Add
config.ymlto.gitignore - Consider using Docker secrets for production:
services:
imap_exporter:
image: ghcr.io/jasminemoeller/imap-exporter:latest
secrets:
- imap_config
command: ["--config", "/run/secrets/imap_config"]
secrets:
imap_config:
file: ./config.yml- ✅ IONOS
- ✅ Gmail (requires app-specific password)
- ✅ Generic IMAP servers
Feel free to report compatibility with other providers!
# Clone the repository
git clone https://github.com/jasminemoeller/imap-exporter.git
cd imap-exporter
# Build the Docker image
docker build -t imap-exporter:latest .
# Run it
docker run -d \
-v $(pwd)/config.yml:/app/config.yml:ro \
-p 9226:9226 \
imap-exporter:latest# Install dependencies
pip install prometheus-client pyyaml
# Run the exporter
python3 imap-exporter.py --config config.yml# Check metrics endpoint
curl http://localhost:9226/metrics
# Expected output:
# imap_quota_used_kb{account="personal"} 6470764.0
# imap_quota_limit_kb{account="personal"} 12582912.0
# imap_up{account="personal"} 1.0- Check IMAP server and port
- Verify firewall rules
- Ensure SSL/TLS is supported on the specified port
- Verify username and password
- For Gmail: use an app-specific password, not your regular password
- Check if 2FA requires special authentication
- Some IMAP servers don't support GETQUOTAROOT
- Check exporter logs for error messages
MIT License - see LICENSE file for details
Contributions welcome! Please feel free to submit a Pull Request.
If you encounter issues or have questions:
- Open an issue on GitHub
- Check existing issues for solutions
See Releases for version history and changes.