Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

API + how to know by API command all machines in ambari cluster

avatar

how to know by API command all machines in ambari cluster ,

example - master01,master02,master03,worker01,worker02,worker03,kafka01,kafka02 etc

Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Guru
2 REPLIES 2

avatar
Guru

avatar
Super Collaborator

You can get the JSON response.

https://github.com/apache/ambari/blob/trunk/ambari-server/docs/api/v1/hosts.md

http://ambari-server:8080/clusters/:clusterName/hosts

To extract the hostnames easier, you could try JSONPath

$.items[*].Hosts.host_name

Or Python with Requests library

r = requests.get('...')
hosts = ','.join(x['Hosts']['host_name'] for x in r.json()['items'])