This commit is contained in:
Fedele Mantuano 2017-09-24 21:17:22 +00:00 committed by GitHub
commit 176a97f8cc
3 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,40 @@
Elasticsearch
=======
This plugin makes easy to use Elasticsearch API and it also offering autocomplete for common APIs.
There are [`GET`](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html),
[`HEAD`](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html),
[`DELETE`](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html),
[`PUT`](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html) and
[`POST`](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html) commands.
Examples usage:
- `GET _cluster/health`
- `GET _nodes/stats`
- `GET _stats/fielddata?fields=*`
- `GET _nodes/stats/indices/fielddata?fields=*`
- `GET _cat`
- `DELETE twitter`
You should install [`json_reformat`](http://dev.man-online.org/package/main/yajl-tools/) to format json output.
Instructions
-------
If you'd prefer to specify an explicit Elasticsearch node client to query, you can set variable like so in `.zshrc`:
`export CLIENT_ELK_NODE=client_node`
Default is `localhost`.
Aliases
-------
- `alias ech='GET _cluster/health'`: Cluster status health
- `alias ecs='GET _cluster/state'`: Allows to get a comprehensive state information of the whole cluster
- `alias ens='GET _nodes/stats'`: Allows to retrieve all of the cluster nodes statistics
- `alias esf='GET _stats/fielddata'`: Field data memory usage on index level
Author
-------
Fedele Mantuano (**Twitter**: [@fedelemantuano](https://twitter.com/fedelemantuano))

View file

@ -0,0 +1,28 @@
#compdef GET
local -a options
options=(
'_cache/clear:Allows to clear all caches for all indices'
'_cat:List of all cat commands'
'_cluster/health:Cluster status health'
'_cluster/nodes/_local/_shutdown:Shutdown local node'
'_cluster/pending_tasks:Returns a list of any cluster-level changes which have not yet been executed'
'_cluster/settings:Cluster settings'
'_cluster/state:Allows to get a comprehensive state information of the whole cluster'
'_cluster/stats:Allows to retrieve statistics from a cluster wide perspective'
'_flush:Allows to flush all indices'
'_nodes/hot_threads:Allowing to get the current hot threads on each node in the cluster'
'_nodes/stats/indices:Field data memory usage on node level'
'_nodes/stats:Allows to retrieve all of the cluster nodes statistics'
'_nodes:Allows to retrieve all of the cluster nodes information'
'_optimize?max_num_segments=1:Allows to optimize all indices'
'_recovery:Cluster-wide recovery status'
'_recovery?detailed=true:Cluster-wide recovery status with details'
'_refresh:Allows to explicitly refresh all indices'
'_segments:Include segments for all indices'
'_shutdown:Shutdown all nodes'
'_stats/fielddata:Field data memory usage on index level'
'_stats:High level aggregation and index level stats for all indices'
'_template:List of all index templates'
)
_describe 'values' options

View file

@ -0,0 +1,27 @@
alias ech='GET _cluster/health'
alias ecs='GET _cluster/state'
alias ens='GET _nodes/stats'
alias esf='GET _stats/fielddata'
if [ -z ${CLIENT_ELK_NODE} ]; then
export CLIENT_ELK_NODE=localhost
fi
# GET
if which json_reformat > /dev/null 2>&1; then
GET() { curl -s -XGET http://${CLIENT_ELK_NODE}:9200/"$@" | json_reformat 2>/dev/null || curl -s -XGET http://${CLIENT_ELK_NODE}:9200/"$@" }
else
GET() { curl -s -XGET http://${CLIENT_ELK_NODE}:9200/"$@" }
fi
# HEAD
HEAD() { curl -s -XHEAD -i http://${CLIENT_ELK_NODE}:9200/"$@" }
# DELETE
DELETE() { curl -s -XDELETE http://${CLIENT_ELK_NODE}:9200/"$@" }
# PUT
PUT() { curl -s -XPUT http://${CLIENT_ELK_NODE}:9200/"$@" }
# POST
POST() { curl -s -XPOST http://${CLIENT_ELK_NODE}:9200/"$@" }