Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Ambari rest API to control flume agent?

avatar
New Contributor

I want to use the rest api to start / stop a specific flume agent rather than the whole flume service.

Working example: I have a 5 node cluster with Ambari on node1, flume agent running on node5.

I can get the URL for the flume agent with:

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X  GET http://node1:8080/api/v1/clusters/Cluster/hosts/node5/host_components

This shows:

http://node1:8080/api/v1/clusters/Cluster/hosts/node5/host_components/FLUME_HANDLER

However if you try to stop it, it stops the whole flume service not just the agent:

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{"HostRoles": {"state": "INSTALLED"}}'  http://node1:8080/api/v1/clusters/Cluster/hosts/node5/host_components/FLUME_HANDLER

Is this possible using REST API?

1 ACCEPTED SOLUTION

avatar
Contributor

Just tested the below in my local environment and worked fine:

curl -u admin:admin -H "X-Requested-By: ambari" -d '{"RequestInfo":{"context":"Stop Flume agent","flume_handler":"agent","operation_level":{"level":"HOST_COMPONENT","cluster_name":"Cluster","service_name":"FLUME","host_name":"node5"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' -X PUT "http://node1:8080/api/v1/clusters/Cluster/hosts/node5/host_components/FLUME_HANDLER"

View solution in original post

3 REPLIES 3

avatar
Contributor

The passing the following:

{ "RequestInfo": { "context": "Stop Flume agent", "flume_handler": "agent", "operation_level": { "level": "HOST_COMPONENT", "cluster_name": "Cluster", "service_name": "FLUME", "host_name": "node5" } }, "Body": { "HostRoles": { "state": "INSTALLED" } } }

avatar
New Contributor

Thanks - what would be the URL for this @stoader. I tried with both the service and the component. e.g.

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{ "RequestInfo": { "context": "Stop Flume agent", "flume_handler": "agent", "operation_level": { "level": "HOST_COMPONENT", "cluster_name": "Cluster", "service_name" "FLUME", "host_name": "node5" } }, "Body": { "HostRoles": { "state": "INSTALLED" } } }' http://node1:8080/api/v1/clusters/Cluster/services/FLUME

and

curl -u admin:admin -i -H 'X-Requested-By: ambari' -X PUT -d '{ "RequestInfo": { "context": "Stop Flume agent", "flume_handler": "agent", "operation_level": { "level": "HOST_COMPONENT", "cluster_name": "Cluster", "service_name" "FLUME", "host_name": "node5" } }, "Body": { "HostRoles": { "state": "INSTALLED" } } }' http://node1:8080/api/v1/clusters/Cluster/hosts/node5/host_components/FLUME_HANDLER

avatar
Contributor

Just tested the below in my local environment and worked fine:

curl -u admin:admin -H "X-Requested-By: ambari" -d '{"RequestInfo":{"context":"Stop Flume agent","flume_handler":"agent","operation_level":{"level":"HOST_COMPONENT","cluster_name":"Cluster","service_name":"FLUME","host_name":"node5"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' -X PUT "http://node1:8080/api/v1/clusters/Cluster/hosts/node5/host_components/FLUME_HANDLER"