Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Query Ambari to get each host/service racks

Solved Go to solution

Query Ambari to get each host/service racks

New Contributor

Do we have any api to get rack info of each /service in an ambari cluster

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Query Ambari to get each host/service racks

Super Mentor

@Manisha Pande

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.

6 REPLIES 6

Re: Query Ambari to get each host/service racks

Super Mentor

@Manisha Pande

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.

Re: Query Ambari to get each host/service racks

New Contributor

@Jay Kumar SenSharma

Thanks Jay!!

My requirement to check each service get host name and rack info.Can we achieve this in one api.

Appreciate your help.

Re: Query Ambari to get each host/service racks

Super Mentor

@Manisha Pande

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?

Highlighted

Re: Query Ambari to get each host/service racks

New Contributor

@Jay Kumar SenSharma

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

--------------------------------------

Re: Query Ambari to get each host/service racks

Super Mentor

@Manisha Pande

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...

.

Re: Query Ambari to get each host/service racks

Super Mentor

@Manisha Pande

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.

Don't have an account?
Coming from Hortonworks? Activate your account here