简介

ResourceManager REST API允许用户获取关于集群的信息——集群上的状态、集群上的指标、调度程序信息、集群中节点的信息以及集群上应用程序的信息。

启用 CORS 支持

只对RM(不支持NM)启用跨原点支持(CORS),请设置以下配置参数:
在core-site.xml内添加 org.apache.hadoop.security.HttpCrossOriginFilterInitializer 到hadoop.http.filter.initializers。在yarn-site.xml内设置yarn.resourcemanager.webapp.cross-origin.enabled 为true

获取集群信息的 API

集群信息资源提供关于集群的总体信息。

  • URI

下面两个都可以获取集群信息

  * http://<rm http address:port>/ws/v1/cluster
  * http://<rm http address:port>/ws/v1/cluster/info
  • HTTP操作支持
get
  • 查询参数支持
none
  • clusterInfo对象的元素
名称类型描述
idlong群集ID
startedOnlong群集开始的时间(从epoch开始以ms为单位)
statestringResourceManager状态-有效值为: NOTINITED, INITED, STARTED, STOPPED
haStatestringResourceManager HA状态-有效值为:INITIALIZING, ACTIVE, STANDBY, STOPPED
rmStateStoreNamestring实现ResourceManager状态存储的类的完全限定名
resourceManagerVersionstringResourceManager的版本号
resourceManagerBuildVersionstring带有生成版本、用户和校验和的ResourceManager生成字符串
resourceManagerVersionBuiltOnstring生成ResourceManager时的时间戳(从epoch起以ms为单位)
hadoopVersionstringHadoop Common版本
hadoopBuildVersionstring具有生成版本、用户和校验和的Hadoop公共生成字符串
hadoopVersionBuiltOnstring
haZooKeeperConnectionStatestring高可用的zk连接状态
  • 请求实例

在这里就以JSON response为例
HTTP Request:

GET http://<rm http address:port>/ws/v1/cluster/info

Response Header:

 HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

Response Body:

{
  "clusterInfo":
  {
    "id":1324053971963,
    "startedOn":1324053971963,
    "state":"STARTED",
    "haState":"ACTIVE",
    "rmStateStoreName":"org.apache.hadoop.yarn.server.resourcemanager.recovery.NullRMStateStore",
    "resourceManagerVersion":"3.0.0-SNAPSHOT",
    "resourceManagerBuildVersion":"3.0.0-SNAPSHOT from unknown by user1 source checksum 11111111111111111111111111111111",
    "resourceManagerVersionBuiltOn":"2016-01-01T01:00Z",
    "hadoopVersion":"3.0.0-SNAPSHOT",
    "hadoopBuildVersion":"3.0.0-SNAPSHOT from unknown by user1 source checksum 11111111111111111111111111111111",
    "hadoopVersionBuiltOn":"2016-01-01T01:00Z",
    "haZooKeeperConnectionState": "ResourceManager HA is not enabled."  }
}

获取集群指标的 API

集群度量资源提供关于集群的一些总体度量。应该从jmx接口检索更详细的指标。

  • URI
 http://<rm http address:port>/ws/v1/cluster/metrics
  • HTTP操作支持
get
  • 查询参数支持
none
  • clusterMetrics对象的元素
名称类型描述
appsSubmittedint提交的 applications 数量
appsCompletedint已完成的 applications 数量
appsPendingint等待中的 applications 数量
appsRunningint运行中的 applications 数量
appsFailedint失败的 applications 数量
appsKilledint已kill掉的 applications 数量
reservedMBlong以MB为单位保留的内存量
availableMBlong可用内存量(MB)
allocatedMBlong已经分配的内存量(MB)
totalMBlong总内存量(MB)
reservedVirtualCoreslong保留的虚拟核数
availableVirtualCoreslong可用虚拟核的数量
allocatedVirtualCoreslong已分配的虚拟核数
totalVirtualCoreslong虚拟核的总数
containersAllocatedint已经分配的容器数
containersReservedint保留的容器数
containersPendingint挂起的容器数
totalNodesint节点总数
activeNodesint活动节点数
lostNodesint丢失的节点数
unhealthyNodesint不正常节点的数目
decommissioningNodesint正在解除授权的节点数
decommissionedNodesint已解除授权的节点数
rebootedNodesint重新启动的节点数
shutdownNodesint关闭的节点数
  • 请求实例

在这里就以JSON response为例
HTTP Request:

GET http://<rm http address:port>/ws/v1/cluster/metrics

Response Header:

 HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

Response Body:

{
  "clusterMetrics":
  {
    "appsSubmitted":0,
    "appsCompleted":0,
    "appsPending":0,
    "appsRunning":0,
    "appsFailed":0,
    "appsKilled":0,
    "reservedMB":0,
    "availableMB":17408,
    "allocatedMB":0,
    "reservedVirtualCores":0,
    "availableVirtualCores":7,
    "allocatedVirtualCores":1,
    "containersAllocated":0,
    "containersReserved":0,
    "containersPending":0,
    "totalMB":17408,
    "totalVirtualCores":8,
    "totalNodes":1,
    "lostNodes":0,
    "unhealthyNodes":0,
    "decommissioningNodes":0,
    "decommissionedNodes":0,
    "rebootedNodes":0,
    "activeNodes":1,
    "shutdownNodes":0
  }
}

获取集群调度的 API

包含集群调度的当前配置信息。它目前支持Fifo、容量和公平调度程序。根据配置的调度程序,您将获得不同的信息,因此请确保查看类型信息

  • URI
http://<rm http address:port>/ws/v1/cluster/scheduler
  • HTTP操作支持
get
  • 查询参数支持
none
  • Capacity Scheduler API

容量调度程序支持分层队列。这一个请求将打印有关所有队列及其所有子队列的信息。实际上可以向其提交作业的队列称为叶队列。这些队列具有与之关联的其他数据。

  • schedulerInfo对象的元素
名称类型描述
typestring调度的类型 - capacityScheduler
capacityfloat配置的队列容量(相对于其父队列的百分比)
usedCapacityfloat已用队列容量百分比
maxCapacityfloat配置的最大队列容量(相对于其父队列的百分比)
queueNamestring队列的名字
queuesarray of queues(JSON)/zero or more queue objects(XML)队列资源的集合
  • the queues object for a Parent queue的元素
名称类型描述
capacityfloat配置的队列容量(相对于其父队列的百分比)
usedCapacityfloat已用队列容量百分比
maxCapacityfloat配置的最大队列容量(相对于其父队列的百分比)
absoluteCapacityfloat此队列可以使用整个群集的绝对容量百分比
absoluteMaxCapacityfloat此队列可以使用整个群集的绝对最大容量百分比
absoluteUsedCapacityfloat此队列使用的整个群集的绝对已用容量百分比
numApplicationsint队列中当前的应用程序数
usedResourcesstring描述队列使用的当前资源的字符串
queueNamestring队列的名字
statestring of QueueState队列的状态
queuesarray of queues(JSON)/zero or more queue objects(XML)子队列信息的集合。如果队列没有子队列,则省略。
resourcesUsedA single resource object此队列使用的资源总量
  • Elements of the queues object for a Leaf queue - contains all the elements in parent except ‘queues’ plus the following
名称类型描述
typeString队列类型 - capacitySchedulerLeafQueueInfo
numActiveApplicationsint此队列中的活着的应用程序数量
numPendingApplicationsint此队列中的挂起的应用程序数量
numContainersint正在使用的容器数
maxApplicationsint此队列可以拥有的最大应用程序数
maxApplicationsPerUserint此队列每个用户可以拥有的最大应用程序数
maxActiveApplicationsint此队列可以拥有的最大活动应用程序数
maxActiveApplicationsPerUserint此队列可以拥有的每个用户的最大活动应用程序数
userLimitint配置中设置的最小用户限制百分比
userLimitFactorfloat配置中设置的用户限制因子
usersarray of users(JSON)/zero or more user objects(XML)包含所用资源的用户对象集合
  • Elements of the user object for users
名称类型描述
usernameString使用资源的用户的用户名
resourcesUsedA single resource object此队列中用户使用的资源量
numActiveApplicationsint此队列中此用户的活动应用程序数
numPendingApplicationsint此队列中此用户的挂起应用程序数
  • Elements of the user object for users
名称类型描述
memoryintThe amount of memory used (in MB)
vCoresint虚拟核的数量
  • 请求实例

在这里就以JSON response为例
HTTP Request:

GET http://<rm http address:port>/ws/v1/cluster/scheduler

Response Header:

 HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

Response Body:

{
    "scheduler": {
        "schedulerInfo": {
            "capacity": 100.0, 
            "maxCapacity": 100.0, 
            "queueName": "root", 
            "queues": {
                "queue": [
                    {
                        "absoluteCapacity": 10.5, 
                        "absoluteMaxCapacity": 50.0, 
                        "absoluteUsedCapacity": 0.0, 
                        "capacity": 10.5, 
                        "maxCapacity": 50.0, 
                        "numApplications": 0, 
                        "queueName": "a", 
                        "queues": {
                            "queue": [
                                {
                                    "absoluteCapacity": 3.15, 
                                    "absoluteMaxCapacity": 25.0, 
                                    "absoluteUsedCapacity": 0.0, 
                                    "capacity": 30.000002, 
                                    "maxCapacity": 50.0, 
                                    "numApplications": 0, 
                                    "queueName": "a1", 
                                    "queues": {
                                        "queue": [
                                            {
                                                "absoluteCapacity": 2.6775, 
                                                "absoluteMaxCapacity": 25.0, 
                                                "absoluteUsedCapacity": 0.0, 
                                                "capacity": 85.0, 
                                                "maxActiveApplications": 1, 
                                                "maxActiveApplicationsPerUser": 1, 
                                                "maxApplications": 267, 
                                                "maxApplicationsPerUser": 267, 
                                                "maxCapacity": 100.0, 
                                                "numActiveApplications": 0, 
                                                "numApplications": 0, 
                                                "numContainers": 0, 
                                                "numPendingApplications": 0, 
                                                "queueName": "a1a", 
                                                "resourcesUsed": {
                                                    "memory": 0, 
                                                    "vCores": 0
                                                }, 
                                                "state": "RUNNING", 
                                                "type": "capacitySchedulerLeafQueueInfo", 
                                                "usedCapacity": 0.0, 
                                                "usedResources": "<memory:0, vCores:0>", 
                                                "userLimit": 100, 
                                                "userLimitFactor": 1.0, 
                                                "users": null
                                            }, 
                                            {
                                                "absoluteCapacity": 0.47250003, 
                                                "absoluteMaxCapacity": 25.0, 
                                                "absoluteUsedCapacity": 0.0, 
                                                "capacity": 15.000001, 
                                                "maxActiveApplications": 1, 
                                                "maxActiveApplicationsPerUser": 1, 
                                                "maxApplications": 47, 
                                                "maxApplicationsPerUser": 47, 
                                                "maxCapacity": 100.0, 
                                                "numActiveApplications": 0, 
                                                "numApplications": 0, 
                                                "numContainers": 0, 
                                                "numPendingApplications": 0, 
                                                "queueName": "a1b", 
                                                "resourcesUsed": {
                                                    "memory": 0, 
                                                    "vCores": 0
                                                }, 
                                                "state": "RUNNING", 
                                                "type": "capacitySchedulerLeafQueueInfo", 
                                                "usedCapacity": 0.0, 
                                                "usedResources": "<memory:0, vCores:0>", 
                                                "userLimit": 100, 
                                                "userLimitFactor": 1.0, 
                                                "users": null
                                            }
                                        ]
                                    }, 
                                    "resourcesUsed": {
                                        "memory": 0, 
                                        "vCores": 0
                                    }, 
                                    "state": "RUNNING", 
                                    "usedCapacity": 0.0, 
                                    "usedResources": "<memory:0, vCores:0>"
                                }, 
                                {
                                    "absoluteCapacity": 7.35, 
                                    "absoluteMaxCapacity": 50.0, 
                                    "absoluteUsedCapacity": 0.0, 
                                    "capacity": 70.0, 
                                    "maxActiveApplications": 1, 
                                    "maxActiveApplicationsPerUser": 100, 
                                    "maxApplications": 735, 
                                    "maxApplicationsPerUser": 73500, 
                                    "maxCapacity": 100.0, 
                                    "numActiveApplications": 0, 
                                    "numApplications": 0, 
                                    "numContainers": 0, 
                                    "numPendingApplications": 0, 
                                    "queueName": "a2", 
                                    "resourcesUsed": {
                                        "memory": 0, 
                                        "vCores": 0
                                    }, 
                                    "state": "RUNNING", 
                                    "type": "capacitySchedulerLeafQueueInfo", 
                                    "usedCapacity": 0.0, 
                                    "usedResources": "<memory:0, vCores:0>", 
                                    "userLimit": 100, 
                                    "userLimitFactor": 100.0, 
                                    "users": null
                                }
                            ]
                        }, 
                        "resourcesUsed": {
                            "memory": 0, 
                            "vCores": 0
                        }, 
                        "state": "RUNNING", 
                        "usedCapacity": 0.0, 
                        "usedResources": "<memory:0, vCores:0>"
                    }, 
                    {
                        "absoluteCapacity": 89.5, 
                        "absoluteMaxCapacity": 100.0, 
                        "absoluteUsedCapacity": 0.0, 
                        "capacity": 89.5, 
                        "maxCapacity": 100.0, 
                        "numApplications": 2, 
                        "queueName": "b", 
                        "queues": {
                            "queue": [
                                {
                                    "absoluteCapacity": 53.7, 
                                    "absoluteMaxCapacity": 100.0, 
                                    "absoluteUsedCapacity": 0.0, 
                                    "capacity": 60.000004, 
                                    "maxActiveApplications": 1, 
                                    "maxActiveApplicationsPerUser": 100, 
                                    "maxApplications": 5370, 
                                    "maxApplicationsPerUser": 537000, 
                                    "maxCapacity": 100.0, 
                                    "numActiveApplications": 1, 
                                    "numApplications": 2, 
                                    "numContainers": 0, 
                                    "numPendingApplications": 1, 
                                    "queueName": "b1", 
                                    "resourcesUsed": {
                                        "memory": 0, 
                                        "vCores": 0
                                    }, 
                                    "state": "RUNNING", 
                                    "type": "capacitySchedulerLeafQueueInfo", 
                                    "usedCapacity": 0.0, 
                                    "usedResources": "<memory:0, vCores:0>", 
                                    "userLimit": 100, 
                                    "userLimitFactor": 100.0, 
                                    "users": {
                                        "user": [
                                            {
                                                "numActiveApplications": 0, 
                                                "numPendingApplications": 1, 
                                                "resourcesUsed": {
                                                    "memory": 0, 
                                                    "vCores": 0
                                                }, 
                                                "username": "user2"
                                            }, 
                                            {
                                                "numActiveApplications": 1, 
                                                "numPendingApplications": 0, 
                                                "resourcesUsed": {
                                                    "memory": 0, 
                                                    "vCores": 0
                                                }, 
                                                "username": "user1"
                                            }
                                        ]
                                    }
                                }, 
                                {
                                    "absoluteCapacity": 35.3525, 
                                    "absoluteMaxCapacity": 100.0, 
                                    "absoluteUsedCapacity": 0.0, 
                                    "capacity": 39.5, 
                                    "maxActiveApplications": 1, 
                                    "maxActiveApplicationsPerUser": 100, 
                                    "maxApplications": 3535, 
                                    "maxApplicationsPerUser": 353500, 
                                    "maxCapacity": 100.0, 
                                    "numActiveApplications": 0, 
                                    "numApplications": 0, 
                                    "numContainers": 0, 
                                    "numPendingApplications": 0, 
                                    "queueName": "b2", 
                                    "resourcesUsed": {
                                        "memory": 0, 
                                        "vCores": 0
                                    }, 
                                    "state": "RUNNING", 
                                    "type": "capacitySchedulerLeafQueueInfo", 
                                    "usedCapacity": 0.0, 
                                    "usedResources": "<memory:0, vCores:0>", 
                                    "userLimit": 100, 
                                    "userLimitFactor": 100.0, 
                                    "users": null
                                }, 
                                {
                                    "absoluteCapacity": 0.4475, 
                                    "absoluteMaxCapacity": 100.0, 
                                    "absoluteUsedCapacity": 0.0, 
                                    "capacity": 0.5, 
                                    "maxActiveApplications": 1, 
                                    "maxActiveApplicationsPerUser": 100, 
                                    "maxApplications": 44, 
                                    "maxApplicationsPerUser": 4400, 
                                    "maxCapacity": 100.0, 
                                    "numActiveApplications": 0, 
                                    "numApplications": 0, 
                                    "numContainers": 0, 
                                    "numPendingApplications": 0, 
                                    "queueName": "b3", 
                                    "resourcesUsed": {
                                        "memory": 0, 
                                        "vCores": 0
                                    }, 
                                    "state": "RUNNING", 
                                    "type": "capacitySchedulerLeafQueueInfo", 
                                    "usedCapacity": 0.0, 
                                    "usedResources": "<memory:0, vCores:0>", 
                                    "userLimit": 100, 
                                    "userLimitFactor": 100.0, 
                                    "users": null
                                }
                            ]
                        }, 
                        "resourcesUsed": {
                            "memory": 0, 
                            "vCores": 0
                        }, 
                        "state": "RUNNING", 
                        "usedCapacity": 0.0, 
                        "usedResources": "<memory:0, vCores:0>"
                    }
                ]
            }, 
            "type": "capacityScheduler", 
            "usedCapacity": 0.0
        }
    }
}

-Fifo Scheduler API
-Fair Scheduler API

获取集群 Applications的 API

通过应用程序API,您可以获得一组资源,每个资源代表一个应用程序。对该资源运行get操作时,将获得应用程序对象的集合.
通过此api可以获得正在运行的applications。

  • URI
http://<rm http address:port>/ws/v1/cluster/apps
  • HTTP操作支持
get
  • 查询参数支持

可以为get操作指定多个参数。开始和完成时间有一个开始和结束参数,允许您指定范围。例如,可以请求在2011年12月19日上午1:00到下午2:00之间启动的所有应用程序,startedTimeBegin=1324256400,startedTimeEnd=1324303200。如果未指定begin参数,则默认为0;如果未指定end参数,则默认为无穷大。

  * state [deprecated] - state of the application (application的状态)
  * states - applications matching the given application states, specified as a comma-separated list.(与给定应用程序状态匹配的应用程序,指定为逗号分隔的列表)
  * finalStatus - the final status of the application - reported by the application itself(应用程序的最终状态-由应用程序本身报告)
  * user - user name (用户名)
  * queue - queue name (队列名)
  * limit - total number of app objects to be returned(要返回的应用程序对象总数)
  * startedTimeBegin - applications with start time beginning with this time, specified in ms since epoch
  * startedTimeEnd - applications with start time ending with this time, specified in ms since epoch
  * finishedTimeBegin - applications with finish time beginning with this time, specified in ms since epoch
  * finishedTimeEnd - applications with finish time ending with this time, specified in ms since epoch
  * applicationTypes - applications matching the given application types, specified as a comma-separated list.(与给定应用程序类型匹配的应用程序,指定为逗号分隔的列表)
  * applicationTags - applications matching any of the given application tags, specified as a comma-separated list.(与任何给定应用程序标记匹配的应用程序,指定为逗号分隔的列表)
  * deSelects - a generic fields which will be skipped in the result.(将在结果中跳过的通用字段)
  • Elements of the apps (Applications) object
名称类型描述
apparray of app objects(JSON)/zero or more application objects(XML)application的集合
  • 请求实例

在这里就以JSON response为例
HTTP Request:

GET http://<rm http address:port>/ws/v1/cluster/apps
可以添加 ?user=*** & state =running等条件

Response Header:

 HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

Response Body:

{
  "apps":
  {
    "app":
    [
      {
        "id": "application_1476912658570_0002",
        "user": "user2",
        "name": "word count",
        "queue": "default",
        "state": "FINISHED",
        "finalStatus": "SUCCEEDED",
        "progress": 100,
        "trackingUI": "History",
        "trackingUrl": "http://host.domain.com:8088/cluster/app/application_1476912658570_0002",
        "diagnostics": "...",
        "clusterId": 1476912658570,
        "applicationType": "MAPREDUCE",
        "applicationTags": "",
        "priority": -1,
        "startedTime": 1476913457320,
        "finishedTime": 1476913761898,
        "elapsedTime": 304578,
        "amContainerLogs": "http://host.domain.com:8042/node/containerlogs/container_1476912658570_0002_02_000001/user2",
        "amHostHttpAddress": "host.domain.com:8042",
        "allocatedMB": 0,
        "allocatedVCores": 0,
        "runningContainers": 0,
        "memorySeconds": 206464,
        "vcoreSeconds": 201,
        "queueUsagePercentage": 0,
        "clusterUsagePercentage": 0,
        "preemptedResourceMB": 0,
        "preemptedResourceVCores": 0,
        "numNonAMContainerPreempted": 0,
        "numAMContainerPreempted": 0,
        "logAggregationStatus": "DISABLED",
        "unmanagedApplication": false,
        "appNodeLabelExpression": "",
        "amNodeLabelExpression": "",
        "resourceRequests": [
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 0
            },
            "relaxLocality": true,
            "resourceName": "*"
        },
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 20
            },
            "relaxLocality": true,
            "resourceName": "host1.domain.com"
        },
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 20
            },
            "relaxLocality": true,
            "resourceName": "host2.domain.com"
        }]
      },
      {
        "id": "application_1476912658570_0001",
        "user": "user1",
        "name": "Sleep job",
        "queue": "default",
        "state": "FINISHED",
        "finalStatus": "SUCCEEDED",
        "progress": 100,
        "trackingUI": "History",
        "trackingUrl": "http://host.domain.com:8088/cluster/app/application_1476912658570_0001",
        "diagnostics": "...",
        "clusterId": 1476912658570,
        "applicationType": "YARN",
        "applicationTags": "",
        "priority": -1,
        "startedTime": 1476913464750,
        "finishedTime": 1476913863175,
        "elapsedTime": 398425,
        "amContainerLogs": "http://host.domain.com:8042/node/containerlogs/container_1476912658570_0001_02_000001/user1",
        "amHostHttpAddress": "host.domain.com:8042",
        "allocatedMB": 0,
        "allocatedVCores": 0,
        "runningContainers": 0,
        "memorySeconds": 205410,
        "vcoreSeconds": 200,
        "queueUsagePercentage": 0,
        "clusterUsagePercentage": 0,
        "preemptedResourceMB": 0,
        "preemptedResourceVCores": 0,
        "numNonAMContainerPreempted": 0,
        "numAMContainerPreempted": 0,
        "logAggregationStatus": "DISABLED",
        "unmanagedApplication": false,
        "appNodeLabelExpression": "",
        "amNodeLabelExpression": "",
        "resourceRequests": [
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 0
            },
            "relaxLocality": true,
            "resourceName": "*"
        },
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 20
            },
            "relaxLocality": true,
            "resourceName": "host3.domain.com"
        },
        {
            "capability": {
                "memory": 4096,
                "virtualCores": 1
            },
            "nodeLabelExpression": "",
            "numContainers": 0,
            "priority": {
                "priority": 20
            },
            "relaxLocality": true,
            "resourceName": "host4.domain.com"
        }]
      }
    ]
  }
}

Cluster Application Statistics(群集应用程序统计信息) API

通过应用程序统计信息API,您可以获得一个三元组集合,每个三元组包含应用程序类型、应用程序状态以及ResourceManager上下文中此类型和此状态的应用程序数。注意,考虑到性能问题,我们目前每个查询最多只支持一个applicationtype。我们将来可能支持每个查询多个应用程序类型以及更多统计信息。对该资源运行get操作时,将获得statitem对象的集合。

  • URI
http://<rm http address:port>/ws/v1/cluster/appstatistics
  • HTTP操作支持
get
  • 查询参数支持

可以指定两个参数。参数不区分大小写。

states -.
applicationTypes -.
  • Elements of the appStatInfo (statItems) object
名称类型描述
statItemarray of statItem objects(JSON)/zero or more statItem objects(XML)The collection of statItem objects
  • 请求实例

在这里就以JSON response为例
HTTP Request:

GET http://<rm http address:port>/ws/v1/cluster/appstatistics?states=accepted,running,finished&applicationTypes=mapreduce

Response Header:

 HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

Response Body:

{
  "appStatInfo":
  {
    "statItem":
    [
       {
          "state" : "accepted",
          "type" : "mapreduce",
          "count" : 4
       },
       {
          "state" : "running",
          "type" : "mapreduce",
          "count" : 1
       },
       {
          "state" : "finished",
          "type" : "mapreduce",
          "count" : 7
       }
    ]
  }
}

Cluster Application API(集群内某个application的api)

应用程序资源包含有关已提交到群集的特定应用程序的信息。

  • URI
 http://<rm http address:port>/ws/v1/cluster/apps/{appid}
  • HTTP操作支持
get
  • 查询参数支持
none
  • Elements of the app (Application) object
名称类型描述
idstringapplication id
userstring启动application的用户
namestringapplication 的name
queuestringapplication被提交到的队列
statestring根据资源管理器的应用程序状态-有效值是yarn应用程序状态枚举的成员: NEW, NEW_SAVING, SUBMITTED, ACCEPTED, RUNNING, FINISHED, FAILED, KILLED
finalStatusstring应用程序的最终状态(如果完成)(由应用程序本身报告)有效值是finalApplicationStatus枚举的成员: UNDEFINED, SUCCEEDED, FAILED, KILLED
progressfloatapplication完成的进度百分比
trackingUIstring跟踪URL当前指向的位置-历史记录(用于历史记录服务器)或ApplicationMaster
trackingUrlstring可用于跟踪应用程序的Web URL
diagnosticsstring详细诊断信息
clusterIdlong群集ID
applicationTypestringapplication 类型
applicationTagsstringapplication 逗号分隔标记
prioritystring提交申请的优先级
startedTimelongapplication 启动的时间(从epoch开始以ms为单位)
finishedTimelongapplication完成的事件 毫秒单位
elapsedTimelongapplication 开始后经过的时间 (in ms)
amContainerLogsstringapplication master container 日志的URL
amHostHttpAddressstringThe nodes http address of the application master
amRPCAddressstringThe RPC address of the application master
allocatedMBintThe sum of memory in MB allocated to the application’s running containers
allocatedVCoresintThe sum of virtual cores allocated to the application’s running containers
runningContainersintThe number of containers currently running for the application
memorySecondslongThe amount of memory the application has allocated (megabyte-seconds)
vcoreSecondslongThe amount of CPU resources the application has allocated (virtual core-seconds)
queueUsagePercentagefloatThe percentage of resources of the queue that the app is using
clusterUsagePercentagefloatThe percentage of resources of the cluster that the app is using.
preemptedResourceMBlongMemory used by preempted container
preemptedResourceVCoreslongNumber of virtual cores used by preempted container
numNonAMContainerPreemptedintNumber of standard containers preempted
numAMContainerPreemptedintNumber of application master containers preempted
logAggregationStatusstringStatus of log aggregation - valid values are the members of the LogAggregationStatus enum: DISABLED, NOT_START, RUNNING, RUNNING_WITH_FAILURE, SUCCEEDED, FAILED, TIME_OUT
unmanagedApplicationbooleanIs the application unmanaged.
appNodeLabelExpressionstringNode Label expression which is used to identify the nodes on which application’s containers are expected to run by default.
amNodeLabelExpressionstringNode Label expression which is used to identify the node on which application’s AM container is expected to run.
  • 请求实例

在这里就以JSON response为例
HTTP Request:

GET http://<rm http address:port>/ws/v1/cluster/apps/application_1476912658570_0002

Response Header:

 HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

Response Body:

{
  "app": {
    "id": "application_1476912658570_0002",
    "user": "user2",
    "name": "word count",
    "queue": "default",
    "state": "FINISHED",
    "finalStatus": "SUCCEEDED",
    "progress": 100,
    "trackingUI": "History",
    "trackingUrl": "http://host.domain.com:8088/cluster/app/application_1476912658570_0002",
    "diagnostics": "...",
    "clusterId": 1476912658570,
    "applicationType": "YARN",
    "applicationTags": "",
    "priority": -1,
    "startedTime": 1476913457320,
    "finishedTime": 1476913761898,
    "elapsedTime": 304578,
    "amContainerLogs": "http://host.domain.com:8042/node/containerlogs/container_1476912658570_0002_02_000001/dr.who",
    "amHostHttpAddress": "host.domain.com:8042",
    "allocatedMB": -1,
    "allocatedVCores": -1,
    "runningContainers": -1,
    "memorySeconds": 206464,
    "vcoreSeconds": 201,
    "queueUsagePercentage": 0,
    "clusterUsagePercentage": 0,
    "preemptedResourceMB": 0,
    "preemptedResourceVCores": 0,
    "numNonAMContainerPreempted": 0,
    "numAMContainerPreempted": 0,
    "logAggregationStatus": "DISABLED",
    "unmanagedApplication": false,
    "appNodeLabelExpression": "",
    "amNodeLabelExpression": ""
  }
}

Cluster Application Attempts API

通过应用程序尝试API,您可以获得表示应用程序尝试的资源集合。在该资源上运行获取操作时,将获取一组应用程序尝试对象。

  • URI
http://<rm http address:port>/ws/v1/cluster/apps/{appid}/appattempts
  • HTTP操作支持
get
  • 查询参数支持
none
  • Elements of the appAttempts object

当您请求应用程序尝试列表时,信息将作为应用程序尝试对象的数组返回。
appAttempts:

名称类型描述
appAttemptarray of app attempt objects(JSON)/zero or more app attempt objects(XML)attempt对象的集合
名称类型描述
idstringThe app attempt id
nodeIdstring尝试运行的节点的节点ID
nodeHttpAddressstring尝试运行的节点的节点的地址
logsLinkstring尝试运行的节点的节点的日志
containerIdstringapplication 尝试的容器ID
startTimelong尝试的开始时间(MS单位)
  • 请求实例

在这里就以JSON response为例
HTTP Request:

GET http://<rm http address:port>/ws/v1/cluster/apps/application_1326821518301_0005/appattempts

Response Header:

 HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

Response Body:

{
   "appAttempts" : {
      "appAttempt" : [
         {
            "nodeId" : "host.domain.com:8041",
            "nodeHttpAddress" : "host.domain.com:8042",
            "startTime" : 1326381444693,
            "id" : 1,
            "logsLink" : "http://host.domain.com:8042/node/containerlogs/container_1326821518301_0005_01_000001/user1",
            "containerId" : "container_1326821518301_0005_01_000001"
         }
      ]
   }
}

Cluster Nodes API

使用nodes API,您可以获得一个资源集合,其中每个资源代表一个节点。在该资源上运行get操作时,将获取节点对象的集合。

Cluster Node API

Cluster Writeable APIs

Cluster New Application API

Cluster Applications API(Submit Application)

Cluster Application State API

Cluster Application Queue API

Cluster Application Priority API

Cluster Delegation Tokens API

Cluster Reservation API List

Cluster Reservation API Create

Cluster Reservation API Submit

Cluster Reservation API Update

Cluster Reservation API Delete

Cluster Application Timeouts API

Cluster Application Timeout API

Cluster Application Timeout Update API

Scheduler Configuration Mutation API

  • URI
  • HTTP操作支持
get
  • 查询参数支持
none
  • clusterMetrics对象的元素
名称类型描述
  • 请求实例

在这里就以JSON response为例
HTTP Request:

Response Header:

 HTTP/1.1 200 OK
  Content-Type: application/json
  Transfer-Encoding: chunked
  Server: Jetty(6.1.26)

Response Body: