A collection of Python scripts for managing Elasticsearch clusters, with a focus on index operations and maintenance tasks.
- Index Management:
- Unfreeze frozen indices
- Reindex index range
-
Python 3.8+
-
Elasticsearch 8.19.1
-
Required Python packages:
elasticsearch==8.19.1
git clone https://github.com/foksk76/elk-scripts.git
cd elk-scriptspython3 -m venv .venv
source .venv/bin/activate # Linux/MacOS
# .venv\Scripts\activate # Windowspip install -r requirements.txtUnfreezes all frozen indices in the cluster.
Usage:
python unfreeze_indices.py [--host HOST] [--username USERNAME] [--password PASSWORD] [--no-verify-certs]Reindex a range of indexes in Elasticsearch.
Usage:
python reindex_elasticsearch.py [--host HOST] [--username USERNAME] [--password PASSWORD] --start-index START_INDEX --end-index END_INDEX [--alias ALIAS] [--no-verify-certs]Command-line arguments:
--host— Elasticsearch host address (default:localhost:9200)--username— Username for authentication (if required)--password— Password for authentication (if required)--start-index— Start index name (e.g.,fg-000001)--end-index— End index name (e.g.,fg-000010)--alias— Alias to assign to the new indices--no-verify-certs— Disable SSL certificate verification (enabled by default)
python unfreeze_indices.py --host https://es-cluster:9200python reindex_elasticsearch.py --host http://localhost:9200 --username elastic --password yourpassword --start-index fg-009783 --end-index fg-009789We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
- Follow PEP 8 guidelines
- Include docstrings for all functions
- Add unit tests for new features
- Update documentation when making changes
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.