Created 04-19-2018 11:23 AM
Do we have any api to get rack info of each /service in an ambari cluster
Created 04-19-2018 11:52 AM
You can use the following Ambari API call:
# curl -u admin:admin -H "X-Requested-By:ambari" -X GET http://ambariserver.example.com:8080/api/v1/clusters/TestCluster/hosts?fields=Hosts/rack_info,Hosts/...
.
Please replace the "TestCluster" with your own cluster name and the ambari hostname in the above URL.
Created 04-19-2018 11:52 AM
You can use the following Ambari API call:
# curl -u admin:admin -H "X-Requested-By:ambari" -X GET http://ambariserver.example.com:8080/api/v1/clusters/TestCluster/hosts?fields=Hosts/rack_info,Hosts/...
.
Please replace the "TestCluster" with your own cluster name and the ambari hostname in the above URL.
Created 04-19-2018 12:03 PM
Thanks Jay!!
My requirement to check each service get host name and rack info.Can we achieve this in one api.
Appreciate your help.
Created 04-19-2018 12:10 PM
Can you please clarify what exactly do you mean by "check each service get host name and rack info"?
In Each service where do you see the rack info?
Created 04-19-2018 12:16 PM
For example , I have two hosts in a cluster hostA, HostB
HostA is on rack-1 and HostB is on rack-2
Services components running in hostA are HDFS_CLINET, ZOOKEEPER,NAMENODE..etc
Services components running in hostB are HBASE, AMABRI_METRICS,DATANODE...etc
I want get result from api like Host: HostA, Service_component : NAMENODE, rack_info: rack-1
HostA, Service_component : ZOOKEEPER, rack_info: rack-1
HostB, Service_component : DATANODE, rack_info: rack-2
--------------------------------------
Created 04-19-2018 12:28 PM
In that case you cane add the "host_components/HostRoles/service_name" part in the same API call to also list the components on each host along with the Rack Info. Burt you will have to parse the output based on your requirement.
Example:
# curl -u admin:admin -H "X-Requested-By:ambari" -X GET http://hdfcluster1.example.com:8080/api/v1/clusters/TestCluster/hosts?fields=Hosts/rack_info,Hosts/h...
.
Created 05-02-2018 01:02 AM
If this answers your query/issue then please mark this HCC thread as answered by clicking on "Accept" link on the correct answer, That way it will help other HCC users to quickly find the answers.