Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tableau Flow Monitor

中文文档

Auto-monitor Tableau Server flow runs and automatically cancel tasks that exceed a time threshold.

Features

  • Checks flow run status every 10 minutes
  • Auto-cancels tasks running longer than 1 hour (configurable)
  • --dry-run mode for safe testing
  • Logs to systemd journal with flow names and job IDs
  • Auto-start on boot, auto-restart on failure

Quick Start

1. Install Dependencies

pip install tableauserverclient python-dotenv

2. Configure

Copy .env.example to .env and fill in your Tableau Server credentials:

cp .env.example .env
vim .env
TABLEAU_SERVER_URL = 'https://your-tableau-server.com'
PERSONAL_ACCESS_TOKEN_NAME = 'your_token_name'
PERSONAL_ACCESS_TOKEN_SECRET = 'your_token_secret'
SITE_NAME = ''

3. Test Run

# 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 --once

4. Deploy as System Service

cat > /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

Usage

# 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

Service Management

# 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

How It Works

  1. Query flow runs from the last 24 hours via Tableau REST API (TSC)
  2. Filter for incomplete runs (completed_at is null) with elapsed time ≥ threshold
  3. Cancel the background job via server.jobs.cancel()
  4. Wait 10 minutes and repeat

Requirements

  • Python 3.8+
  • Tableau Server 2024.2+ (API 3.10+)
  • Personal Access Token

License

MIT

About

Auto monitor and cancel long-running Tableau Server flows

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages