Added environment variable to change client node to query

This commit is contained in:
Fedele Mantuano 2016-03-30 01:58:26 +02:00
commit 9b983f3c6b
3 changed files with 20 additions and 8 deletions

View file

@ -1,4 +1,4 @@
elasticsearch Elasticsearch
======= =======
This plugin makes easy to use Elasticsearch API and it also offering autocomplete for common APIs. 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), There are [`GET`](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html),
@ -17,6 +17,15 @@ Examples usage:
You should install [`json_reformat`](http://dev.man-online.org/package/main/yajl-tools/) to format json output. 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 Aliases
------- -------

View file

@ -23,7 +23,6 @@ options=(
'_shutdown:Shutdown all nodes' '_shutdown:Shutdown all nodes'
'_stats/fielddata:Field data memory usage on index level' '_stats/fielddata:Field data memory usage on index level'
'_stats:High level aggregation and index level stats for all indices' '_stats:High level aggregation and index level stats for all indices'
'_status:Status information of all indices'
'_template:List of all index templates' '_template:List of all index templates'
) )
_describe 'values' options _describe 'values' options

View file

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