Elastro
. * . . * . .
. _ . * . * . *
_ __| | __ _ ___| |_ _ __ ___ .
/ _ \ |/ _` / __| __| '__/ _ \ *
| __/ | (_| \__ \ |_| | | (_) | .
\___|_|\__,_|___/\__|_| \___/ .
. * . * . *
A comprehensive Python module for managing Elasticsearch operations within pipeline processes.
Overview
Elastro is a Python library designed to simplify interactions with Elasticsearch. It provides a clean, intuitive API for common Elasticsearch operations including:
- Index management (create, update, delete)
- Document operations (indexing, searching, updating)
- Datastream management
- Advanced query building and search functionality
- Cluster health assessment and APM/Beats coverage checks
The library offers both a programmatic API and a command-line interface for seamless integration with various workflows.
Table of Contents
- Installation
- Basic Usage (Python API)
- CLI Usage
- ILM (Index Lifecycle Management)
- Snapshot & Restore
- Documentation & Examples
Installation
Global CLI Installation (Recommended)
To heavily simplify installation across all operating systems and elegantly check your Python compatibility, run our automated install.sh via curl:
# WARNING: piping curl to bash skips checksum verification.
# Safer path (recommended): download, inspect, then run:
# curl -sSfL https://raw.githubusercontent.com/Fremen-Labs/elastro/main/install.sh -o /tmp/elastro-install.sh
# less /tmp/elastro-install.sh
# bash /tmp/elastro-install.sh
# Or skip the installer entirely with pipx (below).
curl -sSfL https://raw.githubusercontent.com/Fremen-Labs/elastro/main/install.sh | bash
Alternatively, if you already have pipx installed and your Python version is compatible (>=3.10, <3.14):
# Manual installation via pipx
pipx install elastro-client
# Upgrade later
pipx upgrade elastro-client
Library Installation (For Development)
If you are using Elastro as a library in your Python project:
# Using a virtual environment
python3 -m venv venv
source venv/bin/activate
pip install elastro-client
pip install "elastro-client[ingest-sql]" # optional SQL ingest
Troubleshooting: "externally-managed-environment"
If you see an externally-managed-environment error when running pip install, it means your OS (like macOS with Homebrew) prevents system-wide package installation.
Solution: Use pipx (above) or a virtual environment. Do not use --break-system-packages unless you are certain of the consequences.
Basic Usage
Client Connection
from elastro import ElasticsearchClient
# Connect using API key
client = ElasticsearchClient(
hosts=["https://elasticsearch:9200"], auth={"api_key": "your-api-key"}
)
# Or using basic auth
client = ElasticsearchClient(
hosts=["https://elasticsearch:9200"],
auth={"username": "elastic", "password": "password"},
)
# Connect to Elasticsearch
client.connect()
Index Management
from elastro import IndexManager
index_manager = IndexManager(client)
# Create an index
index_manager.create(
name="products",
settings={"number_of_shards": 3, "number_of_replicas": 1},
mappings={
"properties": {
"name": {"type": "text"},
"price": {"type": "float"},
"description": {"type": "text"},
"created": {"type": "date"},
}
},
)
# Check if an index exists
if index_manager.exists("products"):
print("Products index exists!")
# Delete an index
index_manager.delete("products")
Document Operations
from elastro import DocumentManager
doc_manager = DocumentManager(client)
# Index a document
doc_manager.index(
index="products",
id="1",
document={
"name": "Laptop",
"price": 999.99,
"description": "High-performance laptop",
"created": "2023-05-01T12:00:00",
},
)
# Search for documents
results = doc_manager.search(index="products", query={"match": {"name": "laptop"}})
print(results)
CLI Usage
# Initialize configuration
elastro config init
# Launch the Elastro Local Web GUI
elastro gui
# Create an index
elastro index create products --shards 3 --replicas 1
# Interactive Template Wizard
elastro template wizard
# Interactive ILM Policy Wizard
elastro ilm create my-policy
# List ILM Policies (Table View)
elastro ilm list
# Add a document
elastro doc index products --id 1 --file ./product.json
# Search documents
elastro doc search products --term category=laptop
# Health assessment (scored findings, remediation, rollback)
elastro health assess -o table
elastro health score
elastro health assess --fix --dry-run -o table
elastro health assess --history -o table
elastro health rollback apply --id rb-abc123 --dry-run
elastro health shards --analyze
elastro health hotspots
elastro health lint -o table
# Classic cluster status (prefer over utils health)
elastro health status
# APM/Beats coverage
elastro coverage check --all --skip-absent
elastro -o json coverage fleet status
# Data Ingest & Processing (Client-Side)
elastro ingest import data.csv --index customers --format csv
elastro ingest profile data.csv --sample-size 1000
elastro ingest auto-map data.json --sample-size 500
elastro ingest grok-builder --sample "10.0.0.1 - - [12/May/2026:07:03:12] \"GET /api/v1/users HTTP/1.1\" 200 1234"
# Manage server-side ingest pipelines
elastro ingest pipelines
elastro ingest simulate my-pipeline --docs ./docs.json
# Inspect native realm users and roles
elastro security users
elastro security roles --name kibana_admin
# View long-running cluster tasks
elastro tasks list --detailed
ILM (Index Lifecycle Management)
Elastro provides a powerful CLI for managing ILM policies, including an interactive wizard.
# List all policies (Table View)
elastro ilm list
# List with full JSON details (limited to first 2)
elastro ilm list --full
# Create a policy using the Interactive Wizard (Recommended)
elastro ilm create my-policy
# Follow the prompts to configure Hot, Warm, Cold, and Delete phases.
# Create a policy from a file
elastro ilm create my-policy --file ./policy.json
# Explain lifecycle status for an index (includes step info for debugging)
elastro ilm explain my-index
Snapshot & Restore
Manage backup repositories and snapshots with ease.
Repositories:
# List all repositories
elastro snapshot repo list
# Create a filesystem repository
elastro snapshot repo create my_backup fs --setting location=/tmp/backups
# Create an S3 repository
elastro snapshot repo create my_s3_backup s3 --setting bucket=my-bucket --setting region=us-east-1
Snapshots:
# List snapshots in a repository
elastro snapshot list my_backup
# Create a snapshot (async default)
elastro snapshot create my_backup snapshot_1
# Create and wait for completion
elastro snapshot create my_backup snapshot_2 --wait --indices "logs-*,metrics-*"
# Restore a snapshot (Interactive Wizard)
elastro snapshot restore
# Launches a wizard to select repo -> snapshot -> indices -> rename pattern
# Restore specific indices from CLI
elastro snapshot restore my_backup snapshot_1 --indices "logs-*"
Documentation
For full details, refer to the guides in the docs/ directory:
- 📖 Getting Started
- 🩺 Health Commands
- 💻 CLI Usage
- 📋 Commands Reference
- ⚙️ API Reference
- 🚀 Advanced Features
- 🛠️ Troubleshooting
Examples
Check out the examples directory for more usage examples:
Contributing
We welcome contributions to Elastro! Please see CONTRIBUTING.md for guidelines on how to get started, code standards, and submission processes.
License
MIT
Metadata
Release files for elastro-client 1.14.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| elastro_client-1.14.1.tar.gz | 606.7 kB | Without provenance | Details for elastro_client-1.14.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| elastro_client-1.14.1-py3-none-any.whl | Python 3 | none | any | Details for elastro_client-1.14.1-py3-none-any.whl |
Total release size: 1.1 MB
Release files / elastro_client-1.14.1.tar.gz
| Download URL | elastro_client-1.14.1.tar.gz |
|---|---|
| Size | 606.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2d5b51df1a18fbfde4fe53de63d25d2f07ee5ecd30947a9ccb1f113d31e883a
|
|
BLAKE2b-256 checksum How to use checksums |
caa2eeaa131161d2d8443a88615ce3dadfb3f5c75598c43f95ddd06bff3de396
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.18
|
Release files / elastro_client-1.14.1-py3-none-any.whl
| Download URL | elastro_client-1.14.1-py3-none-any.whl |
|---|---|
| Size | 468.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3794a9f16cb3ba9fed976c507281696bc141440fec9380dc3fefb0534a172509
|
|
BLAKE2b-256 checksum How to use checksums |
1f72b67eefa92369de7903032b76df97fa64b78d2ffd3ae912100cb6b5f74fc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.18
|
Security for elastro-client 1.14.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.