The latest service changes have not yet been reflected in this content. We will update the content as soon as possible. Please refer to the Korean version for information on the latest updates.
Available in VPC
Apache Ambari provides easy Web UI and REST API, simplifying Hadoop cluster management and monitoring. This guide describes how to use Ambari REST API. For more information on Ambari REST API, see Ambari API reference v1.
Compose Ambari REST API's URI
Compose Ambari REST API's URI as follows:
AMBARI-ADDRESS: enter the domain address assigned to the clusterCLUSTER-NAME: name of the cluster (make sure to check the cluster's name as it is case-sensitive)
http://<AMBARI-ADDRESS>:8080/api/v1/clusters/<CLUSTER-NAME>
Request Ambari REST API
Use curl to send a GET request to Ambari REST API.
example/pass123!@#: Ambari's admin account
curl -u "example:pass123!@#" -G "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark"
Run REST API using the above cluster information, and a JSON document like the following one is returned:
Run # curl
curl -u obj -G "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark"
{
"href" : "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark",
"Clusters" : {
"cluster_id" : 2,
"cluster_name" : "SPARK",
"health_report" : {
"Host/stale_config" : 0,
"Host/maintenance_state" : 0,
"Host/host_state/HEALTHY" : 3,
"Host/host_state/UNHEALTHY" : 0,
"Host/host_state/HEARTBEAT_LOST" : 0,
"Host/host_state/INIT" : 0,
"Host/host_status/HEALTHY" : 3,
"Host/host_status/UNHEALTHY" : 0,
"Host/host_status/UNKNOWN" : 0,
"Host/host_status/ALERT" : 0
....
Parse return value using the jq command
You can use jq to filter or convert certain parts of the JSON document returned as a REST API result. Below is an example of filtering only the health_report information from the clusters in JSON results using jq.
curl -u "example:pass123!@#" -G "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark" | jq ".Clusters.health_report"
{
"Host/stale_config": 0,
"Host/maintenance_state": 0,
"Host/host_state/HEALTHY": 4,
"Host/host_state/UNHEALTHY": 0,
"Host/host_state/HEARTBEAT_LOST": 0,
"Host/host_state/INIT": 0,
"Host/host_status/HEALTHY": 4,
"Host/host_status/UNHEALTHY": 0,
"Host/host_status/UNKNOWN": 0,
"Host/host_status/ALERT": 0
}
Examples
Get the fully qualified domain name (FQDN) of all nodes
curl -u "example:pass123!@#" -G "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark/hosts" | jq ".items[].Hosts.host_name"
Get the FQDN of master node
curl -u "example:pass123!@#" -G "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark/services/HDFS/components/NAMENODE" | jq ".host_components[].HostRoles.host_name"
Get the FQDN of worker node
curl -u "example:pass123!@#" -G "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark/services/HDFS/components/DATANODE" | jq ".host_components[].HostRoles.host_name"
Get the internal IP address of a cluster node
To find the IP address, you need the internal FQDN of the cluster node. First, send an Ambari query to find the FQDN of the host node, then send an Ambari query again to find the IP address of each host.
curl -u "example:pass123!@#" -G "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark/hosts/d-002-test-spark-36m-hd" | jq ".Hosts.ip"
Get default.FS
Cloud Hadoop uses Object Storage as the default storage, and the result of the subject API is returned as hdfs://<cluster name (namespace name)>.
curl -u "example:pass123!@#" -G "http://pub-68u67.hadoop.ntruss.com:8080/api/v1/clusters/test-spark/configurations/service_config_versions?service_name=HDFS&service_config_version=1" | jq '.items[].configurations[].properties["fs.defaultFS"] | select(. != null)'