0
votes

I have used rest api to run service check on a hadoop cluster . In Ambari GUI, I can see the request is triggered but API just return below json output.

"href" : "http://:8080/api/v1/clusters/DEMO/requests/11", "Requests" : { "id" : 11, "status" : "Accepted"

This output is same irrespective of run service check status(Pass/Fail) only the request id changes.

How can I interpret , run service check result from above json output ?

1
Can you please provide which API did you use (complete REST call)? - Shubhangi
CURL Command :curl -ivk -H "X-Requested-By: ambari" -u <user>:<password> -X POST -d @payload http://<ambari-server>:8080/api/v1/clusters/<clustername>/requests - Milan Vaibhav
Payload :{ "RequestInfo":{ "context":"HDFS Service Check", "command":"HDFS_SERVICE_CHECK" }, "Requests/resource_filters":[ { "service_name":"HDFS" } ] - Milan Vaibhav

1 Answers

0
votes

Once you issue service check request using REST API, it is accepted by ambari for run and json response is immediately given (before completing service check). Hence response json indicates request id, current status of request and URL to monitor request status.

{
  "href" : "http://localhost:8080/api/v1/clusters/DEMO/requests/182",
  "Requests" : {
    "id" : 182,
    "status" : "Accepted"
  }

You may monitor service check status using URL returned in json response. Example is given below, note "request_status" : "FAILED" indicating if service check was successfully completed or failed.

$ curl -u admin:admin -XGET http://localhost:8080/api/v1/clusters/DEMO/requests/182
{
  "href" : "http://localhost:8080/api/v1/clusters/DEMO/requests/182",
  "Requests" : {
    "aborted_task_count" : 0,
    "cluster_name" : "DEMO",
    "completed_task_count" : 1,
    "create_time" : 1505153613045,
    "end_time" : 1505153724897,
    "exclusive" : false,
    "failed_task_count" : 1,
    "id" : 182,
    "inputs" : "{}",
    "operation_level" : null,
    "progress_percent" : 100.0,
    "queued_task_count" : 0,
    "request_context" : "HDFS Service Check",
    "request_schedule" : null,
    "request_status" : "FAILED",
    "resource_filters" : [
      {
        "service_name" : "HDFS"
      }
    ],
    "start_time" : 1505153613139,
    "task_count" : 1,
    "timed_out_task_count" : 0,
    "type" : "COMMAND"
  },
  "stages" : [
    {
      "href" : "http://localhost:8080/api/v1/clusters/DEMO/requests/182/stages/0",
      "Stage" : {
        "cluster_name" : "DEMO",
        "request_id" : 182,
        "stage_id" : 0
      }
    }
  ],
  "tasks" : [
    {
      "href" : "http://localhost:8080/api/v1/clusters/DEMO/requests/182/tasks/1314",
      "Tasks" : {
        "cluster_name" : "DEMO",
        "id" : 1314,
        "request_id" : 182,
        "stage_id" : 0
      }
    }
  ]
}