Support Questions

Find answers, ask questions, and share your expertise

how to get status of components on specific datanode ( worker machine )

avatar

how to get status of components by REST API on specific datanode ( worker machine )

each datanode worker has the following components

45764-capture.png

REST API should return the status only for the components as describe din the picture per worker machine

second

is it possible to get by REST API the status of datanode alive ?

45765-capture.png

Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Master Mentor

@Michael Bronson

In order to get the State of Each DataNode on different Nodes, you can use the following API call:

Syntax:

# curl -H "X-Requested-By: ambari" -u admin:admin  -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/HDFS/components/DATANODE?fields=host...

.

Example:

# curl -H "X-Requested-By: ambari" -u admin:admin  -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/DATANODE?fiel...
{
  "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/DATANODE?fields=host_components/HostRoles/host_name,host_components/HostRoles/state",
  "ServiceComponentInfo" : {
    "cluster_name" : "plain_ambari",
    "component_name" : "DATANODE",
    "service_name" : "HDFS"
  },
  "host_components" : [
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25101.example.com/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "DATANODE",
        "host_name" : "amb25101.example.com",
        "state" : "STARTED"
      }
    },
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25102.example.com/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "DATANODE",
        "host_name" : "amb25102.example.com",
        "state" : "STARTED"
      }
    },
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25103.example.com/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "DATANODE",
        "host_name" : "amb25103.example.com",
        "state" : "STARTED"
      }
    },
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25104.example.com/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "DATANODE",
        "host_name" : "amb25104.example.com",
        "state" : "STARTED"
      }
    }
  ]

View solution in original post

4 REPLIES 4

avatar
Master Mentor

@Michael Bronson

In order to get the State of Each DataNode on different Nodes, you can use the following API call:

Syntax:

# curl -H "X-Requested-By: ambari" -u admin:admin  -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/HDFS/components/DATANODE?fields=host...

.

Example:

# curl -H "X-Requested-By: ambari" -u admin:admin  -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/DATANODE?fiel...
{
  "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/DATANODE?fields=host_components/HostRoles/host_name,host_components/HostRoles/state",
  "ServiceComponentInfo" : {
    "cluster_name" : "plain_ambari",
    "component_name" : "DATANODE",
    "service_name" : "HDFS"
  },
  "host_components" : [
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25101.example.com/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "DATANODE",
        "host_name" : "amb25101.example.com",
        "state" : "STARTED"
      }
    },
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25102.example.com/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "DATANODE",
        "host_name" : "amb25102.example.com",
        "state" : "STARTED"
      }
    },
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25103.example.com/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "DATANODE",
        "host_name" : "amb25103.example.com",
        "state" : "STARTED"
      }
    },
    {
      "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/hosts/amb25104.example.com/host_components/DATANODE",
      "HostRoles" : {
        "cluster_name" : "plain_ambari",
        "component_name" : "DATANODE",
        "host_name" : "amb25104.example.com",
        "state" : "STARTED"
      }
    }
  ]

avatar
Master Mentor

@Michael Bronson

And if you add "grep -A 1 host_name" in the above API call then you can gt the output as following:

curl -i -H "X-Requested-By: ambari" -u admin:admin  -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/HDFS/components/DATANODE?fiel...  | grep -A 1 host_name 

  "ServiceComponentInfo" : {
--
        "host_name" : "amb25101.example.com",
        "state" : "STARTED"
--
        "host_name" : "amb25102.example.com",
        "state" : "STARTED"
--
        "host_name" : "amb25103.example.com",
        "state" : "STARTED"
--
        "host_name" : "amb25104.example.com",
        "state" : "STARTED"<br>

.

Similarly you can Grep for Non Running DataNode from the above Output.

avatar

@Jay what about <matrix monitor> and <YARN> , meanwhile we see only the component - DATANODE

Michael-Bronson

avatar
Master Mentor

@Michael Bronson

For "Metrics Monitor" status you can alter the API call as following:

# curl -i -H "X-Requested-By: ambari" -u admin:admin  -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/AMBARI_METRICS/components/MET...  | grep -A 1 host_name 


For Yarn Resources like "NODEMANAGER" you can do it like: (Same logic you can apply for RESOURCEMANAGER, APP_TIMELINE_SERVER)

# curl -i -H "X-Requested-By: ambari" -u admin:admin  -X GET http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/services/YARN/components/NODEMANAGER?f...  | grep -A 1 host_name 

..