- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
how to capture all ambari services/components status by API
- Labels:
-
Apache Ambari
-
Apache Hadoop
Created ‎01-02-2018 02:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear colleges
I want to capture all ambari services/components status by API
I need to do so because we developed some scripts that make a lot of change in ambari configuration & restart of some services,
Therefore we need to know what is the services/components status before the changes and what is the services status after the changes
So we need rest API that will capture all ambari services/components status ( as HDFS, YARN Mapreduce , Tez ,Pig , Ziikeper , AMbari metrix , kafka , spark etc )
Expected results Status can be as – fail/ok
Created ‎01-02-2018 04:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can get the state - STARTED/STOPPED by using the below API Calls
For services
curl -u {ambari-username}:{ambari-password} -H "X-Requested-By: ambari" -X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/services/{service-name}?fields=Serv...
For components
curl -u {ambari-username}:{ambari-password} -H "X-Requested-By: ambari" -X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/components/{component-name}?fields=...
To get complete status info about service
curl -u {ambari-username}:{ambari-password} -H "X-Requested-By: ambari" -X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/services/{service-name}
To get complete status info about component
curl -u {ambari-username}:{ambari-password} -H "X-Requested-By: ambari" -X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/components/{component-name}
Replace the place holders like {ambari-username} , {ambari-password}, {ambari-host} , {ambari-port},{clustername} etc with your respective values
Thanks,
Aditya
Created ‎01-02-2018 04:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can refer to https://community.hortonworks.com/articles/81353/popular-ambari-rest-api-commands.html for commands relating to listing of various services etc. It also has link to other ambari API documentation
Created ‎01-02-2018 04:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
not help , see the article its about stop/start others and not as I asked , what I am asking is how to get status from ambari about services / components , and get results as ok / fail
Created ‎01-02-2018 04:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can get the state - STARTED/STOPPED by using the below API Calls
For services
curl -u {ambari-username}:{ambari-password} -H "X-Requested-By: ambari" -X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/services/{service-name}?fields=Serv...
For components
curl -u {ambari-username}:{ambari-password} -H "X-Requested-By: ambari" -X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/components/{component-name}?fields=...
To get complete status info about service
curl -u {ambari-username}:{ambari-password} -H "X-Requested-By: ambari" -X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/services/{service-name}
To get complete status info about component
curl -u {ambari-username}:{ambari-password} -H "X-Requested-By: ambari" -X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/components/{component-name}
Replace the place holders like {ambari-username} , {ambari-password}, {ambari-host} , {ambari-port},{clustername} etc with your respective values
Thanks,
Aditya
Created ‎01-02-2018 05:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok fine , how to get all list of services / components by API in order to use them for the API that U gave me
Created ‎01-02-2018 05:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To get list of services
curl -u {ambari-username}:{ambari-password}-H "X-Requested-By: ambari"-X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/services/{service-name}
To get list of components
curl -u {ambari-username}:{ambari-password}-H "X-Requested-By: ambari"-X GET http://{ambari-host}:{ambari-port}/api/v1/clusters/{clustername}/components/
Created ‎01-02-2018 05:20 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see little problem for example when I check the HDFS with complete status , I not see the status of "stand by namenode" or "ZKfailovercontroler" etc , and for example for YARN we not see the App Timeline Server etc
Created ‎01-02-2018 09:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can get the service components status from the "ServiceComponentInfo/state" parameter.
1. To get all components state in single API:
API : <AMBARI_HOST>/api/v1/clusters/cl1/components?fields=ServiceComponentInfo/state
E.g In the response you can find something like this when MR History server is stopped:
"ServiceComponentInfo": {"cluster_name": "cl1","component_name": "HISTORYSERVER","service_name": "MAPREDUCE2","state": "INSTALLED"}
2. To get more info for individual component, You can use this API resource
<AMBARI_HOST>/api/v1/clusters/cl1/services/MAPREDUCE2/components/HISTORYSERVER
Hopefully this helps!
Created ‎01-03-2018 05:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank you kramakrishnan , regarding step1 can you please show me the full command API syntax
Created ‎01-03-2018 09:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
curl -u {ambari_username}:{ambari_password} -H "X-Requested-By:ambari" -i GET http://localhost:8080/api/v1/clusters/cl1/components?fields=ServiceComponentInfo/state
