
# 查询应用全局拓扑图 - SearchBusinessTopology
#### 功能介绍
查询应用级别全局拓扑图信息。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-apm/apm_04_0007.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-apm/apm_04_0021.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
  
  | 授权项                            | 访问级别 | 资源类型（\*为必须） | 条件键                   | 别名                           | 依赖的授权项 |
  |:---|:---|:---|:---|:---|:---|
  | apm:application:getTransaction | Read | -           | g:EnterpriseProjectId | apm:apm2BusinessBusiness:get | -      |
     
  
 
#### URI
POST /v1/apm2/openapi/topology/business-search
#### 请求参数
表1请求Header参数 
| 参数            | 是否必选 | 参数类型   | 描述                |
|:---|:---|:---|:---|
| X-Auth-Token  | 是    | String | 从IAM服务获取的用户Token。 |
| x-business-id | 是    | Long   | 应用id。             |
   
 表2请求Body参数 
| 参数                 | 是否必选 | 参数类型              | 描述          |
|:---|:---|:---|:---|
| target_business_id | 是    | Long              | 目标应用id。     |
| env_tag_list       | 否    | Array of integers | 环境标签列表，可为空。 |
| direction          | 否    | String            | 方向，可为空。     |
| end_time           | 是    | String            | 结束时间。       |
| start_time         | 是    | String            | 开始时间。       |
| filter_user        | 否    | Boolean           | 过滤。         |
   
#### 响应参数
**状态码： 200**
表3响应Body参数 
| 参数               | 参数类型                                                                                         | 描述           |
|:---|:---|:---|
| node_list        | Array of [TopoNode] objects                      | 组件节点列表。      |
| line_list        | Array of [TopoLine] objects                      | 组件之间调用指向线列表。 |
| collector_config | Map\<String,[CollectorConfigModel]\> | 采集器配置。       |
| real_start_time  | Long                                                                                         | 开始时间。        |
| real_end_time    | Long                                                                                         | 结束时间。        |
   
 表4TopoNode 
| 参数        | 参数类型   | 描述    |
|:---|:---|:---|
| node_type | String | 节点类型。 |
| node_name | String | 节点名称。 |
| node_id   | String | 节点id。 |
| env_id    | Long   | 环境id。 |
   
 表5TopoLine 
| 参数            | 参数类型                 | 描述        |
|:---|:---|:---|
| from_node     | String               | 开始节点。     |
| to_node       | String               | 结束节点。     |
| direction     | String               | 指向。       |
| collector     | String               | 采集器名称。    |
| target_env_id | Long                 | 环境id。     |
| hints         | Map\<String,String\> | 线条上的提示信息。 |
| filter_value  | String               | 过滤值。      |
   
 表6CollectorConfigModel 
| 参数                 | 参数类型                                                                                    | 描述       |
|:---|:---|:---|
| line_view_config   | [LineViewConfigModel] object     | 指向线视图配置。 |
| detail_view_config | [DetailViewConfigModel] object | 详情视图配置。  |
   
 表7LineViewConfigModel 
| 参数                  | 参数类型                                                                            | 描述           |
|:---|:---|:---|
| metric_set          | String                                                                          | 视图对应的指标集的名称。 |
| filter_prefix       | String                                                                          | 过滤参数。        |
| line_view_item_list | Array of [LineViewItem] objects | 视图函数集合。      |
   
 表8LineViewItem 
| 参数       | 参数类型   | 描述   |
|:---|:---|:---|
| function | String | 表达式。 |
| as       | String | 作为。  |
   
 表9DetailViewConfigModel 
| 参数                    | 参数类型                                                                                | 描述           |
|:---|:---|:---|
| metric_set            | String                                                                              | 视图对应的指标集的名称。 |
| group_by              | String                                                                              | 分组类型。        |
| detail_view_item_list | Array of [DetailViewItem] objects | 视图函数集合。      |
   
 表10DetailViewItem 
| 参数       | 参数类型   | 描述   |
|:---|:---|:---|
| function | String | 表达式。 |
| as       | String | 作为。  |
   
#### 请求示例
查询目标应用ID为6，开始时间戳为1667462525000，结束时间戳为1667463725000的应用全局拓扑图信息。
```
/v1/apm2/openapi/topology/business-search
{
  "direction" : "",
  "end_time" : 1667463725000,
  "start_time" : 1667462525000,
  "filter_user" : true,
  "target_business_id" : 6,
  "env_tag_list" : [ ]
}
```
#### 响应示例
**状态码： 200**
OK，请求响应成功。
```
{
  "node_list" : [ {
    "node_type" : "Env",
    "node_name" : "apm-task:cn-east-204",
    "node_id" : "55",
    "env_id" : 55
  }, {
    "node_type" : "Env",
    "node_name" : "apm-api:cn-east-204-az2",
    "node_id" : "45",
    "env_id" : 45
  }, {
    "node_type" : "Env",
    "node_name" : "apm-archive:cn-east-204",
    "node_id" : "4394",
    "env_id" : 4394
  }, {
    "node_type" : "Env",
    "node_name" : "apm-store:cn-east-204-az1",
    "node_id" : "46",
    "env_id" : 46
  }, {
    "node_type" : "Env",
    "node_name" : "apm-store:cn-east-204-az2",
    "node_id" : "47",
    "env_id" : 47
  }, {
    "node_type" : "Env",
    "node_name" : "apm-api:cn-east-204-az1",
    "node_id" : "48",
    "env_id" : 48
  }, {
    "node_type" : "Env",
    "node_name" : "apm-pu-task:cn-east-204-az1",
    "node_id" : "4396",
    "env_id" : 4396
  }, {
    "node_type" : "Env",
    "node_name" : "apm-pu-task:cn-east-204-az2",
    "node_id" : "4397",
    "env_id" : 4397
  }, {
    "node_type" : "Env",
    "node_name" : "apm-deliver:cn-east-204",
    "node_id" : "1104",
    "env_id" : 1104
  }, {
    "node_type" : "Env",
    "node_name" : "apm-merge:cn-east-204",
    "node_id" : "3568",
    "env_id" : 3568
  }, {
    "node_type" : "Mysql",
    "node_name" : "Mysql",
    "node_id" : "Mysql",
    "env_id" : null
  }, {
    "node_type" : "Env",
    "node_name" : "apm-alarm:cn-east-204",
    "node_id" : "913",
    "env_id" : 913
  }, {
    "node_type" : "Env",
    "node_name" : "config-web:cn-east-204",
    "node_id" : "51",
    "env_id" : 51
  }, {
    "node_type" : "Env",
    "node_name" : "user",
    "node_id" : "user",
    "env_id" : null
  }, {
    "node_type" : "Env",
    "node_name" : "apm-access:cn-east-204-AZ1",
    "node_id" : "42",
    "env_id" : 42
  }, {
    "node_type" : "Env",
    "node_name" : "apm-master:cn-east-204",
    "node_id" : "53",
    "env_id" : 53
  }, {
    "node_type" : "Env",
    "node_name" : "apm-front:cn-east-204",
    "node_id" : "54",
    "env_id" : 54
  }, {
    "node_type" : "Env",
    "node_name" : "apm-access:cn-east-204-AZ2",
    "node_id" : "43",
    "env_id" : 43
  } ],
  "line_list" : [ {
    "from_node" : "user",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "0.09",
      "count" : "272",
      "error" : "0"
    },
    "filter_value" : "user"
  }, {
    "from_node" : "47",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "10.28",
      "count" : "780",
      "error" : "0"
    },
    "filter_value" : "47"
  }, {
    "from_node" : "4394",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "29.49",
      "count" : "694",
      "error" : "0"
    },
    "filter_value" : "4394"
  }, {
    "from_node" : "46",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "10.41",
      "count" : "843",
      "error" : "0"
    },
    "filter_value" : "46"
  }, {
    "from_node" : "4397",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "41.54",
      "count" : "175",
      "error" : "0"
    },
    "filter_value" : "4397"
  }, {
    "from_node" : "48",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "39.47",
      "count" : "47",
      "error" : "0"
    },
    "filter_value" : "48"
  }, {
    "from_node" : "4396",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "36.15",
      "count" : "167",
      "error" : "0"
    },
    "filter_value" : "4396"
  }, {
    "from_node" : "51",
    "to_node" : "Mysql",
    "direction" : "out",
    "collector" : "Mysql",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "1.12",
      "count" : "97402",
      "error" : "14"
    },
    "filter_value" : "Mysql"
  }, {
    "from_node" : "1104",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "0.98",
      "count" : "156",
      "error" : "0"
    },
    "filter_value" : "1104"
  }, {
    "from_node" : "913",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "64.91",
      "count" : "686",
      "error" : "0"
    },
    "filter_value" : "913"
  }, {
    "from_node" : "3568",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "30.67",
      "count" : "563",
      "error" : "0"
    },
    "filter_value" : "3568"
  }, {
    "from_node" : "54",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "1.86",
      "count" : "682",
      "error" : "0"
    },
    "filter_value" : "54"
  }, {
    "from_node" : "43",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "1.03",
      "count" : "409",
      "error" : "0"
    },
    "filter_value" : "43"
  }, {
    "from_node" : "42",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "1.26",
      "count" : "401",
      "error" : "0"
    },
    "filter_value" : "42"
  }, {
    "from_node" : "53",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "3.78",
      "count" : "1035",
      "error" : "0"
    },
    "filter_value" : "53"
  }, {
    "from_node" : "45",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "31.25",
      "count" : "48",
      "error" : "0"
    },
    "filter_value" : "45"
  }, {
    "from_node" : "55",
    "to_node" : "51",
    "direction" : "in",
    "collector" : "Url",
    "target_env_id" : 51,
    "hints" : {
      "rt" : "1.13",
      "count" : "94",
      "error" : "0"
    },
    "filter_value" : "55"
  } ],
  "collector_config" : {
    "Mysql" : {
      "line_view_config" : {
        "metric_set" : "total",
        "filter_prefix" : null,
        "line_view_item_list" : [ {
          "function" : "SUM(invokeCount)",
          "as" : "count"
        }, {
          "function" : "SUM(totalTime)/SUM(invokeCount)",
          "as" : "rt"
        }, {
          "function" : "SUM(errorCount)",
          "as" : "errorCount"
        } ]
      },
      "detail_view_config" : {
        "metric_set" : "connection",
        "group_by" : "db",
        "detail_view_item_list" : [ {
          "function" : "SUM(invokeCount)",
          "as" : "count"
        }, {
          "function" : "SUM(totalTime)/SUM(invokeCount)",
          "as" : "rt"
        }, {
          "function" : "SUM(errorCount)",
          "as" : "errorCount"
        } ]
      }
    },
    "Url" : {
      "line_view_config" : {
        "metric_set" : "user",
        "filter_prefix" : "clusterId=",
        "line_view_item_list" : [ {
          "function" : "SUM(invokeCount)",
          "as" : "count"
        }, {
          "function" : "SUM(totalTime)/SUM(invokeCount)",
          "as" : "rt"
        }, {
          "function" : "SUM(errorCount)",
          "as" : "errorCount"
        } ]
      },
      "detail_view_config" : null
    }
  },
  "real_start_time" : 1667465696000,
  "real_end_time" : 1667466896000
}
```
#### 状态码
| 状态码 | 描述                    |
|:---|:---|
| 200 | OK，请求响应成功。            |
| 400 | Bad Request，语义或参数有误。  |
| 401 | Unauthorized，没有权限。    |
| 403 | Forbidden，禁止访问。       |
| 404 | Not Found，没有找到要请求的资源。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-apm/ErrorCode.html)。
