Netflow相关接口
创建流量监控搜集器(CreateFlowCollector)
API请求
URLs
POST zstack/v1/flowmeters/{flowMeterUuid}/collectorsHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"server": "192.168.48.12"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"server":"192.168.48.12"}}' http://localhost:8080/zstack/v1/flowmeters/3d5b7f5cbc1535fc91b5e97ac56221cf/collectors参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| name (可选) | String | body(包含在params结构中) | 资源名称 | 3.6.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.6.0 | |
| flowMeterUuid | String | url | 流量监控资源的uuid | 3.6.0 | |
| server (可选) | String | body(包含在params结构中) | 流量搜集器的ip地址 | 3.6.0 | |
| port (可选) | Long | body(包含在params结构中) | 流量搜集器服务的port | 3.6.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.6.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.0 |
API返回
返回示例
{
"inventory": {
"uuid": "93adc3c5f9c03d3d9aa24cd78bf77d0f",
"server": "192.168.48.12",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | FlowCollectorInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| flowMeterUuid | String | 3.6.0 | |
| server | String | 搜集器IP | 3.6.0 |
| port | Long | 搜集器的UDP端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
CreateFlowCollectorAction action = new CreateFlowCollectorAction();
action.flowMeterUuid = "3d5b7f5cbc1535fc91b5e97ac56221cf";
action.server = "192.168.48.12";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateFlowCollectorAction.Result res = action.call();Python
SDK
CreateFlowCollectorAction action = CreateFlowCollectorAction()
action.flowMeterUuid = "3d5b7f5cbc1535fc91b5e97ac56221cf"
action.server = "192.168.48.12"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateFlowCollectorAction.Result res = action.call()查询流量监控的搜集器(QueryFlowCollector)
API请求
URLs
GET zstack/v1/flowmeters/collectors
GET zstack/v1/flowmeters/collectors/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/flowmeters/collectors?q=uuid=6579310b521d3dd587dd42e73755df6ccurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/flowmeters/collectors/98bab890be3f329d99bb9e67a3f405a1可查询字段
运行CLI命令行工具,输入QueryFlowCollector并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "e231c750a95b301cb4b6de429fa11bbc",
"server": "192.168.48.12",
"port": 2055.0,
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| flowMeterUuid | String | 3.6.0 | |
| server | String | 搜集器IP | 3.6.0 |
| port | Long | 搜集器的UDP端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
QueryFlowCollectorAction action = new QueryFlowCollectorAction();
action.conditions = asList("uuid=cfcc92fcc9143d7eba4f927b8f6e7120");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFlowCollectorAction.Result res = action.call();Python
SDK
QueryFlowCollectorAction action = QueryFlowCollectorAction()
action.conditions = ["uuid=e88fd76aa0a535479d9203a47609103d"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryFlowCollectorAction.Result res = action.call()更新搜集器信息(UpdateFlowCollector)
API请求
URLs
PUT zstack/v1/flowmeters/collectors/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateFlowCollector": {
"server": "192.168.48.12"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateFlowCollector":{"server":"192.168.48.12"}}' http://localhost:8080/zstack/v1/flowmeters/collectors/a08b84909ccf3ace897d565643688b13/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| server (可选) | String | body(包含在updateFlowCollector结构中) | 搜集器的IP | 3.6.0 | |
| port (可选) | Long | body(包含在updateFlowCollector结构中) | UDP端口 | 3.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.0 |
API返回
返回示例
{
"inventory": {
"uuid": "93adc3c5f9c03d3d9aa24cd78bf77d0f",
"server": "192.168.48.12",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | FlowCollectorInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| flowMeterUuid | String | 3.6.0 | |
| server | String | 搜集器IP | 3.6.0 |
| port | Long | 搜集器的UDP端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
UpdateFlowCollectorAction action = new UpdateFlowCollectorAction();
action.uuid = "a08b84909ccf3ace897d565643688b13";
action.server = "192.168.48.12";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateFlowCollectorAction.Result res = action.call();Python
SDK
UpdateFlowCollectorAction action = UpdateFlowCollectorAction()
action.uuid = "a08b84909ccf3ace897d565643688b13"
action.server = "192.168.48.12"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateFlowCollectorAction.Result res = action.call()删除流量监控搜集器(DeleteFlowCollector)
API请求
URLs
DELETE zstack/v1/flowmeters/collectors/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/flowmeters/collectors/4a09dc60a4be305b8a6b1157eedb61bb?deleteMode=Permissive
参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| deleteMode (可选) | String | body | 3.6.0 | ||
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeleteFlowCollectorAction action = new DeleteFlowCollectorAction();
action.uuid = "4a09dc60a4be305b8a6b1157eedb61bb";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteFlowCollectorAction.Result res = action.call();Python
SDK
DeleteFlowCollectorAction action = DeleteFlowCollectorAction()
action.uuid = "4a09dc60a4be305b8a6b1157eedb61bb"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteFlowCollectorAction.Result res = action.call()创建流量监控资源(CreateFlowMeter)
API请求
URLs
POST zstack/v1/flowmetersHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"type": "NetFlow"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"type":"NetFlow"}}' http://localhost:8080/zstack/v1/flowmeters参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| version (可选) | String | body(包含在params结构中) | 流量监控协议的版本号 |
|
3.6.0 |
| type | String | body(包含在params结构中) | 流量监控使用的协议 |
|
3.6.0 |
| sample (可选) | Integer | body(包含在params结构中) | 流量监控的采样率 | 3.6.0 | |
| generateInterval (可选) | Integer | body(包含在params结构中) | 流量监控向搜集器发送的时间间隔 | 3.6.0 | |
| name (可选) | String | body(包含在params结构中) | 资源名称 | 3.6.0 | |
| description (可选) | String | body(包含在params结构中) | 资源的详细描述 | 3.6.0 | |
| server (可选) | String | body(包含在params结构中) | 搜集器的ip地址 | 3.6.0 | |
| port (可选) | Long | body(包含在params结构中) | 搜集器服务的UDP端口 | 3.6.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.6.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.0 |
Note:
- ZStack Cloud创建流量监控资源时支持指定flow的到期间隔,SystemTags增加FLOW_EXPIRE_INTERVAL选项,使用
expireInterval参数来传递 SystemTag。
- 选项格式为:
expireInterval::xx,其中 xx=[1,3600] 单位秒 - 例如:
expireInterval::1200
- 选项格式为:
- ZStack Cloud创建流量监控资源时支持指定flow的timeout配置,SystemTags增加FLOW_ACTIVE_TIMEOUT选项,使用
activeTimeout参数来传递 SystemTag。
- 选项格式为:
activeTimeout::xx,其中 xx单位秒 - 例如:
activeTimeout::3600
- 选项格式为:
API返回
返回示例
{
"inventory": {
"uuid": "5fd98cedd76139a4b0dc68482ac61878",
"type": "NetFlow",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | FlowMeterInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| sample | Long | 流的采样率 | 3.6.0 |
| expireInterval | Long | 流发送间隔 | 3.6.0 |
| version | String | 流量监控协议的版本 | 3.6.0 |
| type | String | 流量监控协议 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| collectors | List | 详情参考collectors | 3.6.0 |
| networkRefs | List | 详情参考networkRefs | 3.6.0 |
#collectors
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| flowMeterUuid | String | 3.6.0 | |
| server | String | 搜集器IP | 3.6.0 |
| port | Long | 搜集器的UDP端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
#networkRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| vRouterUuid | String | 3.6.0 | |
| flowMeterUuid | String | 3.6.0 | |
| l3NetworkUuid | String | 三层网络UUID | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
CreateFlowMeterAction action = new CreateFlowMeterAction();
action.type = "NetFlow";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
CreateFlowMeterAction.Result res = action.call();Python
SDK
CreateFlowMeterAction action = CreateFlowMeterAction()
action.type = "NetFlow"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
CreateFlowMeterAction.Result res = action.call()查询流量监控资源(QueryFlowMeter)
API请求
URLs
GET zstack/v1/flowmeters
GET zstack/v1/flowmeters/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/flowmeters?q=name=testcurl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/flowmeters/84b52e4a84bd3747b3c1429eb47a4f34可查询字段
运行CLI命令行工具,输入QueryFlowMeter并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "4ba598ab40a1321798fb957a9eddb77d",
"type": "NetFlow",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| sample | Long | 流的采样率 | 3.6.0 |
| expireInterval | Long | 流发送间隔 | 3.6.0 |
| version | String | 流量监控协议的版本 | 3.6.0 |
| type | String | 流量监控协议 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| collectors | List | 详情参考collectors | 3.6.0 |
| networkRefs | List | 详情参考networkRefs | 3.6.0 |
#collectors
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| flowMeterUuid | String | 3.6.0 | |
| server | String | 搜集器IP | 3.6.0 |
| port | Long | 搜集器的UDP端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
#networkRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| vRouterUuid | String | 3.6.0 | |
| flowMeterUuid | String | 3.6.0 | |
| l3NetworkUuid | String | 三层网络UUID | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
QueryFlowMeterAction action = new QueryFlowMeterAction();
action.conditions = asList("name=test");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryFlowMeterAction.Result res = action.call();Python
SDK
QueryFlowMeterAction action = QueryFlowMeterAction()
action.conditions = ["name=test"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryFlowMeterAction.Result res = action.call()更新流量监控的信息(UpdateFlowMeter)
API请求
URLs
PUT zstack/v1/flowmeters/{uuid}/actionsHeaders
Authorization: OAuth the-session-uuidBody
{
"updateFlowMeter": {
"version": "V5"
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X PUT -d '{"updateFlowMeter":{"version":"V5"}}' http://localhost:8080/zstack/v1/flowmeters/46191b3339313efaa8a2321490ccd666/actions参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| version (可选) | String | body(包含在updateFlowMeter结构中) | 流量监控协议的版本 |
|
3.6.0 |
| sample (可选) | Long | body(包含在updateFlowMeter结构中) | 流量采集样本率 | 3.6.0 | |
| name (可选) | String | body(包含在updateFlowMeter结构中) | 资源名称 | 3.6.0 | |
| expireInterval (可选) | Long | body(包含在updateFlowMeter结构中) | 流量发送间隔 | 3.6.0 | |
| description (可选) | String | body(包含在updateFlowMeter结构中) | 资源的详细描述 | 3.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.0 |
API返回
返回示例
{
"inventory": {
"collectors": [],
"uuid": "40175d4f6adc33b69926219a69318de4",
"sample": 1.0,
"version": "V5",
"type": "NetFlow",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventory | FlowMeterInventory | 详情参考inventory | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventory
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| sample | Long | 流的采样率 | 3.6.0 |
| expireInterval | Long | 流发送间隔 | 3.6.0 |
| version | String | 流量监控协议的版本 | 3.6.0 |
| type | String | 流量监控协议 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
| collectors | List | 详情参考collectors | 3.6.0 |
| networkRefs | List | 详情参考networkRefs | 3.6.0 |
#collectors
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| name | String | 资源名称 | 3.6.0 |
| description | String | 资源的详细描述 | 3.6.0 |
| flowMeterUuid | String | 3.6.0 | |
| server | String | 搜集器IP | 3.6.0 |
| port | Long | 搜集器的UDP端口 | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
#networkRefs
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| vRouterUuid | String | 3.6.0 | |
| flowMeterUuid | String | 3.6.0 | |
| l3NetworkUuid | String | 三层网络UUID | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
UpdateFlowMeterAction action = new UpdateFlowMeterAction();
action.uuid = "46191b3339313efaa8a2321490ccd666";
action.version = "V5";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
UpdateFlowMeterAction.Result res = action.call();Python
SDK
UpdateFlowMeterAction action = UpdateFlowMeterAction()
action.uuid = "46191b3339313efaa8a2321490ccd666"
action.version = "V5"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
UpdateFlowMeterAction.Result res = action.call()删除流量监控资源(DeleteFlowMeter)
API请求
URLs
DELETE zstack/v1/flowmeters/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/flowmeters/3a65b90e4cbc30b9b90c6defa9d4150d?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuid | String | url | 资源的UUID,唯一标示该资源 | 3.6.0 | |
| deleteMode (可选) | String | body | 3.6.0 | ||
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
DeleteFlowMeterAction action = new DeleteFlowMeterAction();
action.uuid = "3a65b90e4cbc30b9b90c6defa9d4150d";
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
DeleteFlowMeterAction.Result res = action.call();Python
SDK
DeleteFlowMeterAction action = DeleteFlowMeterAction()
action.uuid = "3a65b90e4cbc30b9b90c6defa9d4150d"
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
DeleteFlowMeterAction.Result res = action.call()添加VPC路由器网络到FlowMeter中(AddVRouterNetworksToFlowMeter)
API请求
URLs
POST zstack/v1/flowmeters/{flowMeterUuid}/router/{vRouterUuid}/addnetworksHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"l3NetworkUuids": [
"fc4a406728373583a22ebca19874b2e1"
]
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"l3NetworkUuids":["fc4a406728373583a22ebca19874b2e1"]}}' http://localhost:8080/zstack/v1/flowmeters/2fd1cc7c10023dd880e566f510f043ee/router/5248c2e5e7c0308abc2863c2249fce61/addnetworks参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| flowMeterUuid | String | url | 流量监控资源 | 3.6.0 | |
| vRouterUuid | String | url | VPC路由器的uuid或者VPC路由器组的uuid | 3.6.0 | |
| l3NetworkUuids | List | body(包含在params结构中) | VPC路由器网络的uuid | 3.6.0 | |
| resourceUuid (可选) | String | body(包含在params结构中) | 3.6.0 | ||
| tagUuids (可选) | List | body(包含在params结构中) | 标签UUID列表 | 3.6.0 | |
| systemTags (可选) | List | body | 3.6.0 | ||
| userTags (可选) | List | body | 3.6.0 |
API返回
返回示例
{
"inventories": [
{
"uuid": "b10d1994c1813b9982ab5e52bf07c2e0",
"vRouterUuid": "335d1d3f24c132dba22362dbb4867c7a",
"flowMeterUuid": "f01fef876e503331a4d6b186c41ef1d1",
"l3NetworkUuid": "80b4e4931a8a3760bde3d66f1c03a1ae",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| vRouterUuid | String | 3.6.0 | |
| flowMeterUuid | String | 3.6.0 | |
| l3NetworkUuid | String | 三层网络UUID | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
AddVRouterNetworksToFlowMeterAction action = new AddVRouterNetworksToFlowMeterAction();
action.flowMeterUuid = "2fd1cc7c10023dd880e566f510f043ee";
action.vRouterUuid = "5248c2e5e7c0308abc2863c2249fce61";
action.l3NetworkUuids = asList("fc4a406728373583a22ebca19874b2e1");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
AddVRouterNetworksToFlowMeterAction.Result res = action.call();Python
SDK
AddVRouterNetworksToFlowMeterAction action = AddVRouterNetworksToFlowMeterAction()
action.flowMeterUuid = "2fd1cc7c10023dd880e566f510f043ee"
action.vRouterUuid = "5248c2e5e7c0308abc2863c2249fce61"
action.l3NetworkUuids = [fc4a406728373583a22ebca19874b2e1]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
AddVRouterNetworksToFlowMeterAction.Result res = action.call()查询开启流量监控的VPC网络(QueryVRouterFlowMeterNetwork)
API请求
URLs
GET zstack/v1/flowmeters/networks
GET zstack/v1/flowmeters/networks/{uuid}Headers
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/flowmeters/networks?q=uuid=d515c0ab43ac369e9419c9c861d5c2f7curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/flowmeters/networks/6d67988b515133dea956ddbac0f1d361可查询字段
运行CLI命令行工具,输入QueryVRouterFlowMeterNetwork并按Tab键查看所有可查询字段以及可跨表查询的资源名。
API返回
返回示例
{
"inventories": [
{
"uuid": "62413232b13c3ff496876495906d9254",
"vRouterUuid": "276b37d53794342b8b93f11ffdab0b24",
"flowMeterUuid": "606c59dee3e0371da1b6a829c249bb79",
"l3NetworkUuid": "7d744eec67cb385cb8f55e84056a3a50",
"createDate": "Nov 14, 2017 10:20:57 PM",
"lastOpDate": "Nov 14, 2017 10:20:57 PM"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| inventories | List | 详情参考inventories | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#inventories
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| uuid | String | 资源的UUID,唯一标示该资源 | 3.6.0 |
| vRouterUuid | String | 3.6.0 | |
| flowMeterUuid | String | 3.6.0 | |
| l3NetworkUuid | String | 三层网络UUID | 3.6.0 |
| createDate | Timestamp | 创建时间 | 3.6.0 |
| lastOpDate | Timestamp | 最后一次修改时间 | 3.6.0 |
SDK示例
Java
SDK
QueryVRouterFlowMeterNetworkAction action = new QueryVRouterFlowMeterNetworkAction();
action.conditions = asList("uuid=87600bd6f382333ea003d14514a9d077");
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
QueryVRouterFlowMeterNetworkAction.Result res = action.call();Python
SDK
QueryVRouterFlowMeterNetworkAction action = QueryVRouterFlowMeterNetworkAction()
action.conditions = ["uuid=ac2b106208373677a9d39040d44dd1db"]
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
QueryVRouterFlowMeterNetworkAction.Result res = action.call()流量监控的统计信息(GetVRouterFlowCounter)
API请求
URLs
GET zstack/v1/flowmeters/{vRouterUuid}/counterHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/flowmeters/eee5bf613b913040b6609c2b07efea07/counter参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vRouterUuid | String | url | 路由器uuid | 3.6.0 | |
| systemTags (可选) | List | query | 系统标签 | 3.6.0 | |
| userTags (可选) | List | query | 用户标签 | 3.6.0 |
API返回
返回示例
{
"counters": [
{
"device": "eth1",
"totalEntries": "12",
"totalPkts": "123",
"totalBytes": "12345"
}
]
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
| counters | List | 详情参考counters | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
#counters
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| device | String | 网络接口 | 3.6.0 |
| totalEntries | String | flow总计值 | 3.6.0 |
| totalPkts | String | 总的包数值 | 3.6.0 |
| totalBytes | String | 总的字节值 | 3.6.0 |
SDK示例
Java
SDK
GetVRouterFlowCounterAction action = new GetVRouterFlowCounterAction();
action.vRouterUuid = "eee5bf613b913040b6609c2b07efea07";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetVRouterFlowCounterAction.Result res = action.call();Python
SDK
GetVRouterFlowCounterAction action = GetVRouterFlowCounterAction()
action.vRouterUuid = "eee5bf613b913040b6609c2b07efea07"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetVRouterFlowCounterAction.Result res = action.call()清除VPC路由器网络的流量监控(RemoveVRouterNetworksFromFlowMeter)
API请求
URLs
DELETE zstack/v1/flowmeters/networksHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X DELETE http://localhost:8080/zstack/v1/flowmeters/networks?deleteMode=Permissive参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| uuids | List | body | 3.6.0 | ||
| deleteMode (可选) | String | body | 3.6.0 | ||
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.0 |
API返回
该API成功时返回一个空的JSON结构
{},出错时返回的JSON结构包含一个error字段,例如:{
"error": {
"code": "SYS.1001",
"description": "A message or a operation timeout",
"details": "Create VM on KVM timeout after 300s"
}
}SDK示例
Java
SDK
RemoveVRouterNetworksFromFlowMeterAction action = new RemoveVRouterNetworksFromFlowMeterAction();
action.uuids = asList("aaa9d2325b073fd39a7f1a67b007b1ae");
action.deleteMode = "Permissive";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
RemoveVRouterNetworksFromFlowMeterAction.Result res = action.call();Python
SDK
RemoveVRouterNetworksFromFlowMeterAction action = RemoveVRouterNetworksFromFlowMeterAction()
action.uuids = [aaa9d2325b073fd39a7f1a67b007b1ae]
action.deleteMode = "Permissive"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
RemoveVRouterNetworksFromFlowMeterAction.Result res = action.call()获取流量监控协议中使用的系统标识(GetFlowMeterRouterId)
API请求
URLs
GET zstack/v1/flowmeters/{vRouterUuid}/routeridHeaders
Authorization: OAuth the-session-uuidCurl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X GET http://localhost:8080/zstack/v1/flowmeters/7ca3752b57ef3c8c89257e1eeb720b88/routerid参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vRouterUuid | String | url | VPC路由器的uuid | 3.6.0 | |
| systemTags (可选) | List | query | 系统标签 | 3.6.0 | |
| userTags (可选) | List | query | 用户标签 | 3.6.0 |
API返回
返回示例
{
"routerId": 120.0
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| routerId | Long | 路由器标识 | 3.6.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
SDK示例
Java
SDK
GetFlowMeterRouterIdAction action = new GetFlowMeterRouterIdAction();
action.vRouterUuid = "7ca3752b57ef3c8c89257e1eeb720b88";
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
GetFlowMeterRouterIdAction.Result res = action.call();Python
SDK
GetFlowMeterRouterIdAction action = GetFlowMeterRouterIdAction()
action.vRouterUuid = "7ca3752b57ef3c8c89257e1eeb720b88"
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
GetFlowMeterRouterIdAction.Result res = action.call()设置流量监控协议使用的VPC标识(SetFlowMeterRouterId)
API请求
URLs
POST zstack/v1/flowmeters/{vRouterUuid}/routeridHeaders
Authorization: OAuth the-session-uuidBody
{
"params": {
"routerId": 120.0
},
"systemTags": [],
"userTags": []
}Note: 上述示例中systemTags、userTags字段可以省略。列出是为了表示body中可以包含这两个字段。
Curl示例
curl -H "Content-Type: application/json;charset=UTF-8" \
-H "Authorization: OAuth b86c9016b4f24953a9edefb53ca0678c" \
-X POST -d '{"params":{"routerId":120.0}}' http://localhost:8080/zstack/v1/flowmeters/0bfa81935a6c3dd1a8c68de1874e8a1d/routerid参数列表
| 名字 | 类型 | 位置 | 描述 | 可选值 | 起始版本 |
|---|---|---|---|---|---|
| vRouterUuid | String | url | 3.6.0 | ||
| routerId | Long | body(包含在params结构中) | 路由器标识 | 3.6.0 | |
| systemTags (可选) | List | body | 系统标签 | 3.6.0 | |
| userTags (可选) | List | body | 用户标签 | 3.6.0 |
API返回
返回示例
{
"routerId": 120.0
}| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| routerId | Long | VPC路由器的流量监控标识 | 3.6.0 |
| error | ErrorCode | 错误码,若不为null,则表示操作失败, 操作成功时该字段为null。 详情参考error | 3.6.0 |
#error
| 名字 | 类型 | 描述 | 起始版本 |
|---|---|---|---|
| code | String | 错误码号,错误的全局唯一标识,例如SYS.1000, HOST.1001 | 3.6.0 |
| description | String | 错误的概要描述 | 3.6.0 |
| details | String | 错误的详细信息 | 3.6.0 |
| elaboration | String | 保留字段,默认为null | 3.6.0 |
| opaque | LinkedHashMap | 保留字段,默认为null | 3.6.0 |
| cause | ErrorCode | 根错误,引发当前错误的源错误,若无原错误,该字段为null | 3.6.0 |
SDK示例
Java
SDK
SetFlowMeterRouterIdAction action = new SetFlowMeterRouterIdAction();
action.vRouterUuid = "0bfa81935a6c3dd1a8c68de1874e8a1d";
action.routerId = 120.0;
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c";
SetFlowMeterRouterIdAction.Result res = action.call();Python
SDK
SetFlowMeterRouterIdAction action = SetFlowMeterRouterIdAction()
action.vRouterUuid = "0bfa81935a6c3dd1a8c68de1874e8a1d"
action.routerId = 120.0
action.sessionId = "b86c9016b4f24953a9edefb53ca0678c"
SetFlowMeterRouterIdAction.Result res = action.call()