Esctl
A Command-Line Interface designed to ease Elasticsearch administration.
Key Features • Installation • How To Use • Examples • License • Developing
Esctl is a CLI tool for Elasticsearch. I designed it to shorten huge curl commands Elasticsearch operators were running like :
curl -XPUT --user "john:doe" 'http://elasticsearch.example.com:9200/_cluster/settings' -d '{
"transient" : {
"cluster.routing.allocation.enable": "NONE"
}
}'
The equivalent with esctl is
esctl cluster routing allocation enable none
Key Features
- Easy to use CLI rather than long curl commands (thanks to cliff)
- Cluster-level informations : stats, info, health, allocation explanation
- Node-level informations : list, hot threads, exclusion, stats
- Cluster-level and index-level settings
_catAPI for allocation, plugins and thread pools- Index management : open, close, create, delete, list
rawcommand to perform raw HTTP calls when esctl doesn't provide a nice interface for a given route.- Per-module log configuration
- X-Pack APIs : users and roles
- Multiple output formats : table, csv, json, value, yaml
- JMESPath queries using the
--jmespathflag - Colored output !
- Run arbitrary pre-commands before issuing the call to Elasticsearch (like running
kubectl port-forwardfor example) - Fetch cluster's credentials from external commands instead of having them shown in cleartext in the config file
Installation
Using PIP
pip install esctl
From source
pip install git+https://github.com/jeromepin/esctl.git
How To Use
Esctl relies on a ~/.esctlrc file containing its config. This file is automatically created on the first start if it doesn't exists :
clusters:
bar:
servers:
- https://bar.example.com
users:
john-doe:
username: john
external_password:
command:
run: kubectl --context=bar --namespace=baz get secrets -o json my-secret | jq -r '.data.password||@base64d'
contexts:
foo:
user: john-doe
cluster: bar
default-context: foo
Running pre-commands
Sometimes, you need to execute a shell command right before running the esctl command. Like running a kubectl port-forward in order to connect to your Kubernetes cluster.
There is a pre_commands block inside the context which can take care of that :
clusters:
remote-kubernetes:
servers:
- http://localhost:9200
contexts:
my-distant-cluster:
cluster: remote-kubernetes
pre_commands:
- command: kubectl --context=my-kubernetes-context --namespace=elasticsearch port-forward svc/elasticsearch 9200
wait_for_exit: false
wait_for_output: Forwarding from
user: john-doe
Along with command, you can pass two options :
wait_for_exit(default:true) : wait for the command to exit before continuing. Usually set tofalsewhen the command is running in the foreground.wait_for_output: ifwait_for_exitisfalse, look for a specific output in the command's stdout. The string to look-for is interpreted as a regular expression passed to Python's re.compile().
Examples
License
esctl is licensed under the GNU GPLv3. See LICENCE file.
Developing
Install
make install
Run tests
make test
Format code
make fmt
Metadata
Release files for esctl 1.9.0
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 |
|---|---|---|---|---|
| esctl-1.9.0.tar.gz | 42.6 kB | Without provenance | Details for esctl-1.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| esctl-1.9.0-py3-none-any.whl | Python 3 | none | any | Details for esctl-1.9.0-py3-none-any.whl |
Total release size: 93.1 kB
Release files / esctl-1.9.0.tar.gz
| Download URL | esctl-1.9.0.tar.gz |
|---|---|
| Size | 42.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
15103babfe92b838e3cf1341b390657218aa742a27be3902b65e04bec2d0fe96
|
|
BLAKE2b-256 checksum How to use checksums |
3ba4ab4abaddddca3a028d2f07d81d1f9470379e512f37796957e969ef4fc580
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.11
|
Release files / esctl-1.9.0-py3-none-any.whl
| Download URL | esctl-1.9.0-py3-none-any.whl |
|---|---|
| Size | 50.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a9d90a67f7d100a53129af4b2ebfb9af51d1ba444906293150e78c21ae10f51
|
|
BLAKE2b-256 checksum How to use checksums |
4382e1fc86fd23375ecac3c3302ad683d13ddeba53c70d9dac92403943b5bc83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.11
|
Security for esctl 1.9.0
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.