Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic Search: Make pretty format as the default

Is there a way to make the JSON output of curl commands Pretty printed by default? That is, without specifying the option of ?pretty=true to the curl URL, is it possible to display the output pretty printed everytime?

like image 311
callmekatootie Avatar asked Apr 04 '13 14:04

callmekatootie


People also ask

What is default date format in Elasticsearch?

SSSZ or yyyy-MM-dd .

What is cURL in Elasticsearch?

We use HTTP requests to talk to ElasticSearch. A HTTP request is made up of several components such as the URL to make the request to, HTTP verbs (GET, POST etc) and headers. In order to succinctly and consistently describe HTTP requests the ElasticSearch documentation uses cURL command line syntax.

How do I change the date format in Kibana?

Advanced Settingsedit. Advanced Settings control the behavior of Kibana. For example, you can change the format used to display dates, specify the default data view, and set the precision for displayed decimal values. Open the main menu, then click Stack Management > Advanced Settings.


1 Answers

I was able to accomplish this by adding a new alias to my .bashrc (or .bash_profile on a mac):

alias pp='python -mjson.tool'

Then, after reloading the .bashrc / .bash_profile configuration by opening a new terminal or by running

$ source ~/.bashrc

you can pipe curl output to the 'pp' alias as follows:

$ curl -XGET http://localhost:9200/_search | pp

Source: http://ruslanspivak.com/2010/10/12/pretty-print-json-from-the-command-line/

like image 123
Dan Noble Avatar answered Nov 18 '22 03:11

Dan Noble