Created on 03-27-2018 03:29 PM - edited 08-17-2019 11:09 PM
I am using in my bash script the following API in order to stop the ambari METRICS
curl -u $USER:$PASSWD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo": {"context" :"$METRICS_SERVICE_ACTION AMBARI_METRICS via REST"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}' http://localhost:8080/api/v1/clusters/hdp/services/AMBARI_METRICSthe problem is that Metrics Collector not stopped and also Metrics Monitor on one of the workers machine
so actually ambari METRICS was stop partially
my question is dose my syntax to stop the ambari metrics is the right syntax?
second can we force the Metrics Monitor to stop ?
Created 03-27-2018 03:46 PM
Try this
curl -u $USER:$PASSWD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo":{"context":"_PARSE_.STOP.AMBARI_METRICS","operation_level":{"level":"SERVICE","cluster_name":"hdp","service_name":"AMBARI_METRICS"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://localhost:8080/api/v1/clusters/hdp/services/AMBARI_METRICSMake sure that stop operation is not failed. You can check the operations in ambari UI.
.
Thanks,
Aditya
Created 03-27-2018 03:46 PM
Try this
curl -u $USER:$PASSWD -i -H 'X-Requested-By: ambari'-X PUT -d '{"RequestInfo":{"context":"_PARSE_.STOP.AMBARI_METRICS","operation_level":{"level":"SERVICE","cluster_name":"hdp","service_name":"AMBARI_METRICS"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://localhost:8080/api/v1/clusters/hdp/services/AMBARI_METRICSMake sure that stop operation is not failed. You can check the operations in ambari UI.
.
Thanks,
Aditya
Created 03-27-2018 04:02 PM
I tried your syntax but we get:
curl: (6) Could not resolve host: PUT; Unknown error
HTTP/1.1 400 Bad Request
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=5u0mvfkjcd6v1pa1v5apjaymk;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Content-Length: 131
Server: Jetty(8.1.19.v20160209)
{
  "status" : 400,
  "message" : "Invalid desired state only INIT state allowed during creation, providedDesiredState=INSTALLED"
					
				
			
			
				Created 03-27-2018 04:14 PM
My bad. A space was missing between header and -X put. Use this
curl -u $USER:$PASSWD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"_PARSE_.STOP.AMBARI_METRICS","operation_level":{"level":"SERVICE","cluster_name":"hdp","service_name":"AMBARI_METRICS"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://localhost:8080/api/v1/clusters/hdp/services/AMBARI_METRICS
					
				
			
			
				
			
			
			
			
			
			
			
		Created 03-27-2018 04:17 PM
now we have the output , its ok
HTTP/1.1 202 Accepted
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=1sn5tlp90xkn81kp3n34hterju;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Vary: Accept-Encoding, User-Agent
Content-Length: 135
Server: Jetty(8.1.19.v20160209)
{
  "href" : "http://localhost:8080/api/v1/clusters/hdp/requests/64",
  "Requests" : {
    "id" : 64,
    "status" : "Accepted"
  }
					
				
			
			
				Created 03-27-2018 04:19 PM
@Aditya what is the syntax for ambari metrics start ?
Created 03-27-2018 04:24 PM
This is the curl call for start
curl -u $USER:$PASSWD -i -H 'X-Requested-By: ambari' -X PUT -d '{"RequestInfo":{"context":"_PARSE_.START.AMBARI_METRICS","operation_level":{"level":"SERVICE","cluster_name":"hdp","service_name":"AMBARI_METRICS"}},"Body":{"ServiceInfo":{"state":"STARTED"}}}' http://localhost:8080/api/v1/clusters/hdp/services/AMBARI_METRICS