Easy to use CLI tool to manage Elasticsearch, preventing long curl commands.
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file esctl-1.9.0.tar.gz.
File metadata
- Download URL: esctl-1.9.0.tar.gz
- Upload date:
- Size: 42.6 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15103babfe92b838e3cf1341b390657218aa742a27be3902b65e04bec2d0fe96
|
|
| MD5 |
a52f20bc5c6dee97a525330295458487
|
|
| BLAKE2b-256 |
3ba4ab4abaddddca3a028d2f07d81d1f9470379e512f37796957e969ef4fc580
|
File details
Details for the file esctl-1.9.0-py3-none-any.whl.
File metadata
- Download URL: esctl-1.9.0-py3-none-any.whl
- Upload date:
- Size: 50.5 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a9d90a67f7d100a53129af4b2ebfb9af51d1ba444906293150e78c21ae10f51
|
|
| MD5 |
80236e24121737ee1410e4b63d7acc25
|
|
| BLAKE2b-256 |
4382e1fc86fd23375ecac3c3302ad683d13ddeba53c70d9dac92403943b5bc83
|