Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

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'])