Cloudera APIs

First we need to find the api version:
# curl -u username:password -X GET http://<cloudera-manager>:7180/api/version
v11
List all hosts:
# curl -u username:password -X GET http://<cloudera-manager>:7180/api/v11/hosts
 }, {
    "hostId" : "551a1241-32f2-4bd6-82f0-652b100c6433",
    "ipAddress" : "192.168.3.151",
    "hostname" : "<hostname>",
    "rackId" : "/default",
    "hostUrl" : "http://<cloudera-manager>:7180/cmf/hostRedirect/551a1241-32f2-4bd6-82f0-652b100c6433",
    "maintenanceMode" : false,
    "maintenanceOwners" : [ ],
    "commissionState" : "COMMISSIONED",
    "numCores" : 40,
    "numPhysicalCores" : 20,
    "totalPhysMemBytes" : 135215247360
.
..
...
List all clusters:
$ curl -u username:password -X GET http://<cloudera-manager>:7180/api/v11/clusters
{
  "items" : [ {
    "name" : "cluster",
    "displayName" : "Cluster 1",
    "version" : "CDH5",
    "fullVersion" : "5.5.1",
    "maintenanceMode" : false,
    "maintenanceOwners" : [ ],
    "clusterUrl" : "http://<cloudera-manager>:7180/cmf/clusterRedirect/cluster",
    "hostsUrl" : "http://<cloudera-manager>:7180/cmf/clusterRedirect/cluster/hosts",
    "entityStatus" : "CONCERNING_HEALTH"
  } ]
Select the name or display name of cluster from above list to get the services:
$ curl -u username:password -X GET http://<cloudera-manager>:7180/api/v11/clusters/cluster/services
Entire roles and reference hostid for the hdfs service:
$ curl -u username:password -X GET http://<cloudera-manager>:7180/api/v11/clusters/cluster/services/hdfs/roles
Show the role types of a service:
$ curl -u username:password -X GET http://<cloudera-manager>:7180/api/v11/clusters/cluster/services/hdfs/roleTypes
{
  "items" : [ "DATANODE", "NAMENODE", "SECONDARYNAMENODE", "BALANCER", "GATEWAY", "HTTPFS", "FAILOVERCONTROLLER", "JOURNALNODE", "NFSGATEWAY" ]
}
List all applications running now and the details (like no: of maps, if hive then)
$ curl -u username:password -X GET http://<cloudera-manager>:7180/api/v11/clusters/cluster/services/yarn/yarnApplications
List cloudera manager services:
$ curl -u username:password -X GET http://<cloudera-manager>:7180/api/v11/cm/service
List services installed on a host and overall host status:
$ curl -u username:password -X GET http://<cloudera-manager>:7180/api/v11/hosts/77dcf4d3-9423-4ed8-908a-913d895115a4 (hostid)
0 Comments

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *