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.

AMBARI REST API + how to verify if specific service required restart

Solved Go to solution
Highlighted

AMBARI REST API + how to verify if specific service required restart

hi all

 

how to verify if specific service required restart?

 

for example - HDFS service

 

in case HDFS service required restart then ambari will show this as

 

Capture.PNG

 

is it possible by rest api to understand if service required restart or not? 

 

for example for - YARN / HIVE , etc

Michael-Bronson
1 ACCEPTED SOLUTION

Accepted Solutions

Re: AMBARI REST API + how to verify if specific service required restart

Super Mentor

@mike_bronson7

If you just want to find out specific services like HDFS / HIVE /SPARK2 to know whether they require restart or not then you can do this using filtering option service_name.in(xxx,yyy,zzz)

 

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&HostRoles/service_name.in(HIVE,HDFS,SPARK2)"

 

 

Various Options to get Stale Config Component/Service details.
Similarly there are few other variants of the API call to find out and list the Services/Individual components which require restart.

 

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET  "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&fields=HostRoles/service_name,HostRoles/host_name"

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true"

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&fields=HostRoles/service_name"

 


How to restart All Stale Configurations using API call.

 

# curl -u admin:admin -H "X-Requested-By: ambari" -X POST -d  '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/requests"

 


.

Please change the Ambari Hostname/port and Cluster name in the above API calls.
I have changed "http://" to "ttp://"  Please correct that protocol prefix before using the above mentioned API calls.

View solution in original post

9 REPLIES 9
Highlighted

Re: AMBARI REST API + how to verify if specific service required restart

Contributor
Highlighted

Re: AMBARI REST API + how to verify if specific service required restart

but I am asking diff , we want API that ask about specific service as HDFS or YARN , etc 

this post that you mentioned ( https://community.cloudera.com/t5/Support-Questions/how-to-know-if-any-service-in-ambari-cluster-nee... ) is about all services that required restart 

 

note  -  what we want is API that ask the specific service if required restart or not

Michael-Bronson
Highlighted

Re: AMBARI REST API + how to verify if specific service required restart

Mentor

@mike_bronson7 

 

Can you run the below it should give the desired response

 

curl -u admin:admin -H "X-Requested-By:ambari" -X GET "http://<ambari-server>:<port>/api/v1/clusters/<clustername>/host_components?HostRoles/stale_configs=false&fields=HostRoles/service_name

 

Please let me know

 

Highlighted

Re: AMBARI REST API + how to verify if specific service required restart

I get A long list of all services , , any way not see there the HDFS

 

but what we want is to verify only specific one service 

 

 

 

Michael-Bronson
Highlighted

Re: AMBARI REST API + how to verify if specific service required restart

Mentor

@mike_bronson7 

I will not have access  to my environment  for 4 days as I am traveling but  I think you can filter using 

service_name=HDFS

 I need to test that but that's the way 

Highlighted

Re: AMBARI REST API + how to verify if specific service required restart

Dear Shelton ,

 

enjoy your vacation , and be careful from the corona -:)

 

Michael-Bronson
Highlighted

Re: AMBARI REST API + how to verify if specific service required restart

any way just for your information we get that

 

curl -u admin:admin -H "X-Requested-By:ambari" -X GET "http://master_node:8080/api/v1/clusters/HDP/host_components?HostRoles/stale_configs=false&fields=HostRoles/service_name=HDFS"
{
"status" : 400,
"message" : "Unable to compile query predicate: Invalid Query Token: token='=', previous token type=VALUE_OPERAND"

Michael-Bronson

Re: AMBARI REST API + how to verify if specific service required restart

Super Mentor

@mike_bronson7

If you just want to find out specific services like HDFS / HIVE /SPARK2 to know whether they require restart or not then you can do this using filtering option service_name.in(xxx,yyy,zzz)

 

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&HostRoles/service_name.in(HIVE,HDFS,SPARK2)"

 

 

Various Options to get Stale Config Component/Service details.
Similarly there are few other variants of the API call to find out and list the Services/Individual components which require restart.

 

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET  "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&fields=HostRoles/service_name,HostRoles/host_name"

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true"

# curl -u admin:admin -H "X-Requested-By: ambari" -X GET "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/host_components?HostRoles/stale_configs=true&fields=HostRoles/service_name"

 


How to restart All Stale Configurations using API call.

 

# curl -u admin:admin -H "X-Requested-By: ambari" -X POST -d  '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' "ttp://kerlatest1.example.com:8080/api/v1/clusters/KerLatest/requests"

 


.

Please change the Ambari Hostname/port and Cluster name in the above API calls.
I have changed "http://" to "ttp://"  Please correct that protocol prefix before using the above mentioned API calls.

View solution in original post

Highlighted

Re: AMBARI REST API + how to verify if specific service required restart

Dear Jay

 

what to say

 

excellent answer , you are really one of the best here 

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