
# 获取原始数据表格 - ShowRawTable
#### 功能介绍
获取原始数据表格。
#### 调用方法
请参见[如何调用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::getConf | Read | -           | -   | - apm:apm2BusinessView:get  - apm:apm2Service:get   | -      |
     
  
 
#### URI
POST /v1/apm2/openapi/view/metric/raw-table
#### 请求参数
表1请求Header参数 
| 参数            | 是否必选 | 参数类型   | 描述                |
|:---|:---|:---|:---|
| X-Auth-Token  | 是    | String | 从IAM服务获取的用户Token。 |
| x-business-id | 是    | Long   | 应用id。             |
   
 表2请求Body参数 
| 参数              | 是否必选 | 参数类型                                                       | 描述          |
|:---|:---|:---|:---|
| last_row_id     | 否    | String                                                     | 上一次扫描的数据ID。 |
| view_config     | 是    | [RawTableView] object | 原始数据表格视图。   |
| page            | 是    | Integer                                                    | 当前页码。       |
| page_size       | 是    | Integer                                                    | 每页数据总数。     |
| order_by        | 否    | String                                                     | 排序。         |
| search_word     | 否    | String                                                     | 搜索关键字。      |
| instance_id     | 否    | Long                                                       | 实例id。       |
| monitor_item_id | 否    | Long                                                       | 监控项id。      |
| env_id          | 是    | Long                                                       | 环境id。       |
| start_time      | 是    | String                                                     | 开始时间。       |
| end_time        | 是    | String                                                     | 结束时间。       |
   
 表3RawTableView 
| 参数              | 是否必选 | 参数类型                                                           | 描述                                                                                                                                                                                                                                                                                                                                        |
|:---|:---|:---|:---|
| view_type       | 否    | String                                                         | 视图类型。 枚举值： - **trend**  - **sumtable**  - **rawtable**   |
| collector_name  | 是    | String                                                         | 采集器名称。                                                                                                                                                                                                                                                                                                                                    |
| metric_set      | 是    | String                                                         | 视图对应的指标集的名称。                                                                                                                                                                                                                                                                                                                              |
| title           | 是    | String                                                         | 图标所需展示的标题。                                                                                                                                                                                                                                                                                                                                |
| table_direction | 是    | String                                                         | 表格的方向，H：默认，表头横向，V：表头纵向。 枚举值： - **H**  - **V**                                                                          |
| group_by        | 是    | String                                                         | 分组规则。                                                                                                                                                                                                                                                                                                                                     |
| filter          | 是    | String                                                         | 过滤列表模型。                                                                                                                                                                                                                                                                                                                                   |
| field_item_list | 是    | Array of [FieldItem] objects | 所需展示的字段列表模型集合。                                                                                                                                                                                                                                                                                                                            |
| span            | 是    | Boolean                                                        | 跨度。                                                                                                                                                                                                                                                                                                                                       |
| span_field      | 是    | String                                                         | 跨度字段。                                                                                                                                                                                                                                                                                                                                     |
| order_by        | 否    | String                                                         | 排序规则。                                                                                                                                                                                                                                                                                                                                     |
| latest          | 否    | Boolean                                                        | 是否只展示最近一笔数据。                                                                                                                                                                                                                                                                                                                              |
   
 表4FieldItem 
| 参数            | 是否必选 | 参数类型    | 描述        |
|:---|:---|:---|:---|
| function      | 是    | String  | 表达式。      |
| as            | 否    | String  | 作为。       |
| default_value | 否    | String  | 默认值。      |
| trace         | 否    | Boolean | 是否是trace。 |
| precision     | 否    | Integer | 百分比。      |
| unit          | 否    | String  | 单位。       |
| visible       | 否    | Boolean | 是否可见。     |
   
#### 响应参数
**状态码： 200**
表5响应Body参数 
| 参数               | 参数类型                                                          | 描述                                                                                                                                                                                                                                                                    |
|:---|:---|:---|
| row_list         | Array of [FrontRow] objects | 数据行。                                                                                                                                                                                                                                                                  |
| latest_data_Time | String                                                        | 最近一笔数据的时间。                                                                                                                                                                                                                                                            |
| table_direction  | String                                                        | 表格的方向，H：默认，表头横向，V：表头纵向。 枚举值： - **H**  - **V**   |
| result_id        | String                                                        | 上次请求id。                                                                                                                                                                                                                                                               |
| real_start_time  | Long                                                          | 实际开始的时间，主要用于下一次调用，特别是分页调用的时候传的参数。                                                                                                                                                                                                                                     |
| real_end_time    | Long                                                          | 实际结束的时间。                                                                                                                                                                                                                                                              |
   
 表6FrontRow 
| 参数        | 参数类型                                                            | 描述                                |
|:---|:---|:---|
| cell_list | Array of [FrontCell] objects | 数据单元集合。                           |
| filter    | String                                                          | 将group by的字段拼接成过滤字符串，用于后续点网格单击使用。 |
| header    | Boolean                                                         | 是否是header信息。                      |
| tx_id     | Long                                                            | Url跟踪id。                          |
   
 表7FrontCell 
| 参数         | 参数类型    | 描述                       |
|:---|:---|:---|
| data_type  | String  | 数据类型。                    |
| function   | String  | 函数。                      |
| trace      | Boolean | 是否调用链。                   |
| span       | Boolean | 是否是span信息，如果是就跳到调用链搜索页面。 |
| span_field | String  | span字段。                  |
| precision  | Integer | 小数点位数。                   |
| text       | String  | 文本信息。                    |
| unit       | String  | 单位。                      |
| visible    | Boolean | 是否可见。                    |
   
#### 请求示例
入参为view_type参数为rawtable的视图配置，可从查询监控项配置信息接口获取。
```
/v1/apm2/openapi/view/metric/raw-table
{
  "end_time" : 1667436600000,
  "env_id" : "913",
  "instance_id" : "13",
  "monitor_item_id" : 10499,
  "page" : 1,
  "page_size" : 10,
  "search_word" : "",
  "start_time" : 1667435400000,
  "view_config" : {
    "span" : null,
    "latest" : null,
    "collector_name" : "Exception",
    "metric_set" : "exception",
    "title" : "异常堆栈",
    "table_direction" : null,
    "group_by" : "",
    "filter" : "className=com.*.*.*.*.apm.alarm.service.impl.AviatorService^exceptionType=java.lang.ClassCastException^logType=sl4j_logback_error",
    "field_item_list" : [ {
      "trace" : null,
      "function" : "stackTrace",
      "as" : "异常堆栈",
      "default_value" : null,
      "precision" : null,
      "unit" : null,
      "visible" : true
    } ],
    "span_field" : null,
    "view_type" : "rawtable"
  }
}
```
#### 响应示例
**状态码： 200**
OK，请求响应成功。
```
{
  "row_list" : [ {
    "header" : true,
    "cell_list" : [ {
      "span" : null,
      "trace" : null,
      "data_type" : "STRING",
      "function" : null,
      "span_field" : null,
      "precision" : null,
      "text" : "time",
      "unit" : null,
      "visible" : true
    }, {
      "span" : null,
      "trace" : null,
      "data_type" : "CLOB",
      "function" : null,
      "span_field" : null,
      "precision" : null,
      "text" : "异常堆栈",
      "unit" : null,
      "visible" : true
    } ],
    "filter" : null,
    "tx_id" : null
  }, {
    "header" : null,
    "cell_list" : [ {
      "span" : null,
      "trace" : null,
      "data_type" : null,
      "function" : null,
      "span_field" : null,
      "precision" : null,
      "text" : "2022-11-03 08:41:00",
      "unit" : null,
      "visible" : true
    }, {
      "span" : null,
      "trace" : null,
      "data_type" : null,
      "function" : null,
      "span_field" : null,
      "precision" : null,
      "text" : "6-973f4c1c78928bcf67d67dfaccc9d3a09f3cef97b2de70bd11f103a1af449b94",
      "unit" : null,
      "visible" : true
    } ],
    "filter" : null,
    "tx_id" : null
  } ],
  "latest_data_Time" : "2022-11-03 08:41:00",
  "table_direction" : "H",
  "result_id" : null,
  "real_start_time" : 1667435400000,
  "real_end_time" : 1667436600000
}
```
#### 状态码
| 状态码 | 描述                    |
|:---|:---|
| 200 | OK，请求响应成功。            |
| 400 | Bad Request，语义或参数有误。  |
| 401 | Unauthorized，没有权限。    |
| 403 | Forbidden，禁止访问。       |
| 404 | Not Found，没有找到要请求的资源。 |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-apm/ErrorCode.html)。
