Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Ambari rest API to control flume agent?

avatar
New Member

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
New Member

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
New Member

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 Member

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
New Member

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"