Auto-monitor Tableau Server flow runs and automatically cancel tasks that exceed a time threshold.
- Checks flow run status every 10 minutes
- Auto-cancels tasks running longer than 1 hour (configurable)
--dry-runmode for safe testing- Logs to systemd journal with flow names and job IDs
- Auto-start on boot, auto-restart on failure
pip install tableauserverclient python-dotenvCopy .env.example to .env and fill in your Tableau Server credentials:
cp .env.example .env
vim .envTABLEAU_SERVER_URL = 'https://your-tableau-server.com'
PERSONAL_ACCESS_TOKEN_NAME = 'your_token_name'
PERSONAL_ACCESS_TOKEN_SECRET = 'your_token_secret'
SITE_NAME = ''# Check once, no cancellation (safe test)
python monitor_long_flows.py --once --dry-run
# Check once, actually cancel timed-out tasks
python monitor_long_flows.py --oncecat > /etc/systemd/system/tableau-monitor.service << 'EOF'
[Unit]
Description=Tableau Flow Monitor - Auto cancel long-running flows
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/tableau-monitor
ExecStart=/usr/bin/python3 /opt/tableau-monitor/monitor_long_flows.py
Restart=on-failure
RestartSec=60
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable tableau-monitor
systemctl start tableau-monitor# Default: check every 10min, cancel if > 1h
python monitor_long_flows.py
# Dry run (check only, no cancellation)
python monitor_long_flows.py --dry-run
# Custom timeout (2 hours)
python monitor_long_flows.py --timeout 2
# Combined
python monitor_long_flows.py --dry-run --timeout 0.5
# Run once and exit
python monitor_long_flows.py --once# Check status
systemctl status tableau-monitor
# View live logs
journalctl -u tableau-monitor -f
# View recent logs
journalctl -u tableau-monitor --since "10 min ago"
# Stop / Restart
systemctl stop tableau-monitor
systemctl restart tableau-monitor- Query flow runs from the last 24 hours via Tableau REST API (TSC)
- Filter for incomplete runs (
completed_atis null) with elapsed time ≥ threshold - Cancel the background job via
server.jobs.cancel() - Wait 10 minutes and repeat
- Python 3.8+
- Tableau Server 2024.2+ (API 3.10+)
- Personal Access Token
MIT