Thanks to visit codestin.com
Credit goes to github.com

Skip to content

foksk76/elk-scripts

Repository files navigation

Elasticsearch Administration Scripts

Python Elasticsearch License

A collection of Python scripts for managing Elasticsearch clusters, with a focus on index operations and maintenance tasks.

Table of Contents

Features

  • Index Management:
    • Unfreeze frozen indices
    • Reindex index range

Requirements

  • Python 3.8+

  • Elasticsearch 8.19.1

  • Required Python packages:

    elasticsearch==8.19.1
    

Installation

1. Clone the Repository

git clone https://github.com/foksk76/elk-scripts.git
cd elk-scripts

2. Set Up Virtual Environment (Recommended)

python3 -m venv .venv
source .venv/bin/activate  # Linux/MacOS
# .venv\Scripts\activate  # Windows

3. Install Dependencies

pip install -r requirements.txt

Scripts

unfreeze_indices.py

Unfreezes all frozen indices in the cluster.

Usage:

python unfreeze_indices.py [--host HOST] [--username USERNAME] [--password PASSWORD] [--no-verify-certs]

reindex_elasticsearch.py

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)

Usage Examples

Basic Unfreeze Operation

python unfreeze_indices.py --host https://es-cluster:9200

Basic Reindex Operation

python reindex_elasticsearch.py --host http://localhost:9200 --username elastic --password yourpassword --start-index fg-009783 --end-index fg-009789

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature/your-feature)
  5. Open a Pull Request

Coding Standards

  • Follow PEP 8 guidelines
  • Include docstrings for all functions
  • Add unit tests for new features
  • Update documentation when making changes

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

About

Elasticsearch Administration Scripts

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages