Support Questions

Find answers, ask questions, and share your expertise

Guys can anyone tell me if we can get components status (running,stopped) from ambari REST API's .

avatar
Expert Contributor

Team,

I want to read Ambari alerts through NIFI using REST API's . Please let me know if its feasible to do it .

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Bharadwaj Bhimavarapu

Based on the thread title you want to know how to get components status (running,stopped) from ambari REST API's?

However later you mentioned that "you want to read Ambari alerts through NIFI using REST API's", Can you please clarify which alert are you getting and Are you sure that you want to read the component status from Alerts?

- If you simply want to read the component status (like NIFI) then you can make the following kind of REST Curl call:

curl -u admin:admin -H "X-Requested-By:ambari" -i -X GET http://localhost:8080/api/v1/clusters/Sandbox/hosts/sandbox.hortonworks.com/host_components/NIFI_MAS...

.

OR more precisely

curl -u admin:admin -H "X-Requested-By:ambari" -i -X GET http://localhost:8080/api/v1/clusters/Sandbox/hosts/sandbox.hortonworks.com/host_components/NIFI_MAS...

Example output will be something like:

15220-nifi-state.png

.

View solution in original post

5 REPLIES 5

avatar

Yes, you can get component status using ambari Rest API's.

curl -u admin:admin -H "X-Requested-By:ambari" -i -X POST http://sandbox.hortonworks.com:8080/api/v1/clusters/Sandbox/services/NIFI

Below is a good article:

https://community.hortonworks.com/articles/30289/working-with-ambari-rest-api-automate-nifi-install....

avatar
Expert Contributor

@Namit Maheshwari when I try the above .. its actually creating the service . Please find below the status I got from curl function .

curl -u admin:'XXXX' -H "X-Requested-By:ambari" -i -X POST http://XXXX:8080/api/v1/clusters/HDF_DEV/services/NIFI HTTP/1.1 409 Conflict X-Frame-Options: DENY X-XSS-Protection: 1; mode=block Set-Cookie: AMBARISESSIONID=1rb3hvd20fc9g1rcuezfvw84fg;Path=/;HttpOnly Expires: Thu, 01 Jan 1970 00:00:00 GMT User: admin Content-Type: text/plain Content-Length: 128 Server: Jetty(8.1.19.v20160209)

{ "status" : 409, "message" : "Attempted to create a service which already exists: , clusterName=HDF_DEV serviceName=NIFI"

I was thinking to use nifi and check all the services for HDP components .

avatar
Master Mentor

@Bharadwaj Bhimavarapu

Based on the thread title you want to know how to get components status (running,stopped) from ambari REST API's?

However later you mentioned that "you want to read Ambari alerts through NIFI using REST API's", Can you please clarify which alert are you getting and Are you sure that you want to read the component status from Alerts?

- If you simply want to read the component status (like NIFI) then you can make the following kind of REST Curl call:

curl -u admin:admin -H "X-Requested-By:ambari" -i -X GET http://localhost:8080/api/v1/clusters/Sandbox/hosts/sandbox.hortonworks.com/host_components/NIFI_MAS...

.

OR more precisely

curl -u admin:admin -H "X-Requested-By:ambari" -i -X GET http://localhost:8080/api/v1/clusters/Sandbox/hosts/sandbox.hortonworks.com/host_components/NIFI_MAS...

Example output will be something like:

15220-nifi-state.png

.

avatar
Expert Contributor

@Jay SenSharma Hi Jay.. Thanks for the details .. this is what I am looking for.

avatar
Master Mentor
@Bharadwaj Bhimavarapu

Good to know that the detail was useful.

It will be great if you can click on the "Accept" link on this thread and mark this thread as "Answered", that will be useful for other users as well.