Reply
Expert Contributor
Posts: 263
Registered: ‎01-25-2017

Cloudera manager API json response as one line

[ Edited ]

Hi Guys,

 

I'm working to send the yarn applications meta data using the API to kibana,

 

But the API json response is pretty and kibana accepts the json as one line.

 

Below is one of the example i do, can anyone help me to know how to get this as one line?

 

curl -u 'xxxxx:'xxxxx' 'http://svvr-cmc101.lpdomain.com:7180/api/v11/clusters/cluster/services/yarn/yarnApplications?from=20...)'

Highlighted
Cloudera Employee
Posts: 212
Registered: ‎07-08-2013

Re: Cloudera manager API json response as one line

[ Edited ]

Workaround would be to parse it in python/bash(tr,awk,sed)/perl to remove the line breaks, an easier option is to use ./jq -c -- see [0]

 

curl -s -X GET -u xxxxx:xxxxx http://cm-server:7180/api/v11/.... | jq -c

 

[0] https://stedolan.github.io/jq/manual/#Invokingjq

--compact-output / -c:

By default, jq pretty-prints JSON output. 
Using this option will result in more compact output by
instead putting each JSON object on a single line.

 

Announcements