Code Monkey home page Code Monkey logo

escli's Introduction

elastic.go - A command-line tool to query the Elasticsearch REST API

elastic.go was born to turn commands that look like this:

curl -XGET 'http://localhost:9200/_nodes/_all/host,ip' | python -m json.tool

into this:

elastic node list

elastic fetches data from your Elasticsearch instance, formats the data nicely when it is JSON compressed data, and adds a bit of colors to make it more readable to the human eye. It aims at providing shortcuts for all default Elasticsearch routes. For instance, you can get the cluster health with elastic cluster health (or elastic c he for short).

Of course, you can still issue any GET requests with elastic query <YOUR REQUEST HERE> (or elastic q for short), like elastic q twitter/tweet,user/_search?q=user:kimchy'. By design, only GET requests are allowed. I wanted to make it easy to query Elasticseach indexes, not deleting them so use the good old curl -XDELETE ... if this is what you want to achieve. There is currently no support for PUT requests either since I have no use for it. Pull requests are welcome however.

Installation

Providing that Go is installed and that $GOPATH is set, simply use the following command:

go get -u github.com/Rolinh/elastic-go

Make sure that $GOPATH/bin is in your $PATH.

Build a Docker image

A Dockerfile is provided. Simply run the following command to build the Docker image:

docker build -t Rolinh/elastic-go .

Usage

elastic help provides general help:

$ elastic help
NAME:
   elastic - A command line tool to query the Elasticsearch REST API

USAGE:
   elastic [global options] command [command options] [arguments...]

VERSION:
   1.0.0

AUTHOR(S):
   Robin Hahling <[email protected]>

COMMANDS:
   cluster, c   Get cluster information
   index, i     Get index information
   node, n      Get cluster nodes information
   query, q     Perform any ES API GET query
   stats, s     Get statistics
   help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --baseurl "http://localhost:9200/"   Base API URL
   --help, -h                           show help
   --version, -v                        print the version

Help works for any subcommand as well. For instance:

$ elastic index help
NAME:
   elastic index - Get index information

USAGE:
   elastic index [global options] command [command options] [arguments...]

VERSION:
   1.0.0

COMMANDS:
   docs-count, dc       Get index documents count
   list, l              List all indexes
   size, si             Get index size
   status, st           Get index status
   verbose, v           List indexes information with many stats
   help, h              Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h   show help

escli's People

Contributors

ashatch avatar pataquets avatar rolinh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.