A comprehensive Python toolkit to analyze and visualize Cassandra token ring distribution with advanced features for multi-datacenter support, historical analysis, and rebalancing recommendations.
This tool parses Cassandra nodetool ring output files and generates a circular visualization showing:
- Token distribution across nodes (color-coded by node)
- Token ranges owned by each node
- Gaps or holes in the token ring (shown in white)
- Load statistics and balance metrics
ring-project/
├── README.md # This file
├── ADVANCED_FEATURES.md # Advanced features guide
├── requirements.txt # Python dependencies
├── cassandra_ring_analyzer.py # Main analyzer script
├── multi_dc_analyzer.py # Multi-datacenter support
├── interactive_visualizer.py # Interactive HTML visualizations
├── historical_analyzer.py # Historical trend analysis
├── rebalancing_advisor.py # Rebalancing recommendations
├── docs/
│ └── cassandra_ring_analyzer_spec.md # Technical specification
└── example-output/ # Example visualizations
- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtBasic usage:
python cassandra_ring_analyzer.py ringWith options:
python cassandra_ring_analyzer.py ring -o output.png --dpi 300 --showpositional arguments:
ring_file Path to nodetool ring output file
optional arguments:
-h, --help Show this help message and exit
-o, --output FILE Output image file (default: ring_visualization.png)
--format FORMAT Output format: png, pdf, svg (default: png)
--dpi DPI Image resolution (default: 300)
--size WxH Figure size in inches (default: 12x10)
--show Display plot interactively
--stats-only Print statistics without visualization
-v, --verbose Verbose output
The tool generates a circular ring diagram with:
- Each node represented by a unique color
- Token ranges shown as colored segments
- Gaps/holes shown in white
- Legend with node information and statistics
Cassandra Ring Analysis Summary
================================
Datacenter: dc3
Total Nodes: 3
Total Tokens: 48
Node Distribution:
10.142.94.18: 16 tokens (33.3%) - Load: 3.37 TiB
10.142.94.19: 16 tokens (33.3%) - Load: 1.31 TiB
10.142.94.20: 16 tokens (33.3%) - Load: 1.26 TiB
Token Space Coverage:
Owned: 95.2%
Gaps: 4.8% (3 gaps detected)
Balance Score: 0.92 (1.0 = perfect balance)
- Token Distribution Analysis: Calculate and visualize how tokens are distributed across nodes
- Gap Detection: Identify missing token ranges in the ring
- Color-Coded Visualization: Each node gets a unique color for easy identification
- Statistics: Comprehensive metrics including balance score, coverage, and load distribution
- Multiple Output Formats: Save as PNG, PDF, or SVG
- Interactive Mode: View the visualization interactively with matplotlib
- Multi-Datacenter Support: Analyze and compare multiple datacenters in a single view
- Interactive Visualizations: Create zoomable, hoverable HTML dashboards with Plotly
- Historical Analysis: Track ring changes over time and identify trends
- Rebalancing Recommendations: Get intelligent suggestions for improving ring balance
See ADVANCED_FEATURES.md for detailed documentation.
- Python 3.7+
- matplotlib >= 3.5.0
- numpy >= 1.21.0
- plotly >= 5.0.0 (for interactive features)
- pandas >= 1.3.0 (for advanced analysis)
python cassandra_ring_analyzer.py ring.txt -o visualization.pngpython multi_dc_analyzer.py ring.txt --comparison -o dc_comparison.pngpython interactive_visualizer.py ring.txt --dashboard --showpython historical_analyzer.py ring_before.txt ring_after.txtpython rebalancing_advisor.py ring.txt --export-json rebalancing_plan.jsonADVANCED_FEATURES.md- Complete guide to advanced featuresdocs/cassandra_ring_analyzer_spec.md- Technical specification
MIT License
Contributions are welcome! Please feel free to submit issues or pull requests.