全部产品
Search
文档中心

专有网络 VPC:CreateTrafficMirrorSession - 创建流量镜像会话

更新时间:Aug 28, 2026

调用CreateTrafficMirrorSession创建镜像会话。

接口说明

CreateTrafficMirrorSession 接口属于异步接口,即系统返回一个实例 ID,但该镜像会话尚未创建成功,系统后台的创建任务仍在进行。您可以调用 ListTrafficMirrorSessions 查询镜像会话的创建状态:

  • 当镜像会话处于 Creating 状态时,表示镜像会话正在创建中。

  • 当镜像会话处于 Created 状态时,表示镜像会话创建完成。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

当前API暂无授权信息透出。

请求参数

名称

类型

必填

描述

示例值

TrafficMirrorSessionDescription

string

镜像会话的描述信息。

描述长度为 1~256 个字符,不能以http://https://开头。

This is a trafficmirrorsession.

TrafficMirrorSessionName

string

镜像会话的名称。

名称长度为 1~128 个字符,不能以http://https://开头。

test

ClientToken

string

客户端 Token,用于保证请求的幂等性。

从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符。

说明

若您未指定,则系统自动使用 API 请求的 RequestId 作为 ClientToken 标识。每次 API 请求的 RequestId 不一样。

0c593ea1-3bea-11e9-b96b-88e9fe63****

DryRun

boolean

是否只预检此次请求,取值:

  • true:发送检查请求,不会创建镜像会话。检查项包括是否填写了必需参数、请求格式和限制。如果检查不通过,则返回对应错误。如果检查通过,则返回错误码DryRunOperation

  • false(默认值):发送正常请求,通过检查后直接创建镜像会话。

false

TrafficMirrorTargetId

string

镜像目的的实例 ID,目前支持弹性网卡和私网负载均衡实例作为镜像目的。

eni-j6c8znm5l1yt4sox****

TrafficMirrorTargetType

string

镜像目的类型,取值:

  • NetworkInterface:弹性网卡。

  • SLB:私网负载均衡实例。

NetworkInterface

TrafficMirrorFilterId

string

流量镜像筛选条件的实例 ID。

tmf-j6cmls82xnc86vtpe****

VirtualNetworkId

integer

指定 VNI(VXLAN Network Identifier),用来区分不同的镜像流量,取值范围为 0~16777215

您可以通过 VNI 在镜像目的区分不同会话的镜像流量。您可以自定义 VNI 的值,也可以由系统随机分配该值。如果由系统随机分配该值,请不传该参数。

1

Priority

integer

镜像会话的优先级,取值范围为 1~32766。 数字越小,优先级越高。同一账号在同一个地域创建的镜像会话优先级不能重复。

1

Enabled

boolean

是否开启流量会话,取值:

  • false(默认值):不开启流量会话。

  • true:开启流量会话。

false

PacketLength

integer

指定被镜像的原始报文长度(不包含 VXLAN 报文长度),默认值 1500,取值范围:648500,单位:字节。

  • 该参数的大小会影响镜像目的收到的报文长度,详情请参见流量镜像概述中的镜像报文长度和 MTU 限制。

  • 该参数仅在部分地域可用,详情请参见创建和管理流量镜像中的镜像报文长度参数描述。

1500

TrafficMirrorSourceIds

array

镜像源的实例 ID,目前支持弹性网卡作为镜像源。其中 N 的默认值为 1,即一个镜像会话只支持添加一个镜像源。

eni-j6c2fp57q8rr47rp****

string

镜像源的实例 ID,目前支持弹性网卡作为镜像源。其中 N 的默认值为 1,即一个镜像会话只支持添加一个镜像源。

eni-j6c2fp57q8rr47rp****

RegionId

string

镜像会话的所属地域 ID。您可以通过调用 DescribeRegions 接口获取地域 ID。关于流量镜像支持的地域,请参见流量镜像概述

cn-hongkong

ResourceGroupId

string

流量镜像所属的资源组 ID。

rg-bp67acfmxazb4ph****

Tag

array<object>

资源的标签。

object

标签。

Key

string

资源的标签键。最多支持输入 20 个标签键。如需传入该值,则不能输入空字符串。

一个标签键最多支持 128 个字符,不能以aliyunacs:开头,不能包含http://或者https://

FinanceDept

Value

string

资源的标签值。最多支持输入 20 个标签值。如需传入该值,可以输入空字符串。

最多支持 128 个字符,不能以aliyunacs:开头,不能包含http://或者https://

FinanceJoshua

返回参数

名称

类型

描述

示例值

object

镜像会话的实例 ID。

TrafficMirrorSessionId

string

镜像会话的实例 ID。

tms-j6ce5di4w7nvigfjz****

RequestId

string

请求 ID。

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

ResourceGroupId

string

流量镜像所属的资源组 ID。

rg-bp67acfmxazb4ph****

示例

正常返回示例

JSON格式

{
  "TrafficMirrorSessionId": "tms-j6ce5di4w7nvigfjz****",
  "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
  "ResourceGroupId": "rg-bp67acfmxazb4ph****"
}

错误码

HTTP status code

错误码

错误信息

描述

400 IncorrectBusinessStatus.TrafficMirror The business status of traffic mirror is incorrect. 流量镜像的商业状态不正确。
400 OptInRequired.TrafficMirror You need to subscribe to the traffic mirror service first. 未开通流量镜像服务。
400 DuplicatedParam.SourceInstanceIds The parameter of source instance IDs contains duplicate values. 流量镜像源实例ID参数中包含重复值。
400 OperationDenied.DuplicateRole The network interface must not be the source and the target of traffic mirror sessions at the same time. 网卡不能同时作为流量镜像会话的源和目的。
400 ResourceNotFound.NetworkInterface The specified resource of %s is not found. 指定的NetworkInterface %s 不存在
400 ResourceNotFound.EcsInstance The specified resource of ECS instance is not found. 指定的ECS实例不存在。
400 ResourceNotFound.Slb The specified resource of SLB is not found. 指定的SLB不存在。
400 OperationDenied.SlbNotInVpc The specified SLB is not in any VPC. 指定的SLB不属于任何一个VPC。
400 ResourceNotFound.TrafficMirrorFilter The specified resource of traffic mirror filter is not found. 指定的流量镜像筛选条件不存在。
400 IncorrectStatus.TrafficMirrorFilter The status of traffic mirror filter is incorrect. 流量镜像筛选条件的状态不正确。
400 OperationDenied.EcsNotSupportTrafficMirror The ECS instance does not support traffic mirroring. ECS实例不支持流量镜像功能。
400 QuotaExceeded.SessionNum The quota of the number of traffic mirror sessions is exceeded. 流量镜像会话数量超限。
400 QuotaExceeded.FilterRelatedSession The quota of the number of traffic mirror sessions related to one filter is exceeded. 流量镜像筛选条件所关联的镜像会话数量配额超限。
400 QuotaExceeded.SourceNumPerSession The quota of the number of traffic mirror sources per session is exceeded. 每个流量镜像会话所允许关联的源的数量配额超限。
400 QuotaExceeded.NetworkInterfaceRelatedSession The quota of the number of traffic mirror sessions related to one network interface is exceeded. 单个网卡所能关联的流量镜像会话数量配额超限。
400 QuotaExceeded.SlbRelatedSession The quota of the number of traffic mirror sessions related to one SLB is exceeded. 单个SLB所能关联的流量镜像会话数量配额超限。
400 UnsupportedRegion The feature is not supported in current region. 当前地域不支持该功能。
400 InvalidLoadBalancerId.NotFound The specified resource of load balancer is not found. 指定的SLB实例不存在。
400 OperationDenied.FreeNetworkInterface The network interface is not attached to any ECS instance. 指定的网卡未绑定任何ECS实例。
400 OperationDenied.ClassicSLB The operation is not allowed because of ClassicSLB. 当前操作不支持传统型负载均衡实例
400 ResourceNotFound.TargetInstance The specified target instance for traffic mirroring is not found. 指定的流量镜像目标实例不存在。
400 QuotaExceeded.SourceNumPerTarget The maximum number of traffic mirror sources for a target is exceeded. 该镜像目标关联的镜像源数量超过限额。
400 IncorrectStatus.NetworkInterface The status of network interface is incorrect. 弹性网卡状态不正确。
400 OperationFailed.NotSupportBizType The specified instance type does not support the operation. 操作失败因为指定的实例类型不支持此操作。
400 IllegalParam.Priority The specified Priority is illegal or the same as other mirroring sessions. 指定的Priority不合法或与其他的镜像会话相同
400 OperationDenied.UnsupportedTargetType Traffic mirror target must be SLB if traffic mirror sources contain nat gateway network interface. 流量镜像源中存在NAT网关网卡时,流量镜像目的必须为SLB类型
400 OperationDenied.TargetTypeNotSupportGatewayLoadBalancerEndpoint Operation denied because of target type can not be GatewayLoadBalancerEndpoint. 网关型负载均衡终端节点不支持作为流量镜像目的。
400 OperationDenied.TargetTypeNotSupportBondEni Operation denied because of target type can not be Bond Network Interface. Bond弹性网卡不支持作为镜像目的。
400 OperationDenied.InvalidTargetBondEniType The traffic mirroring target does not support the entered bond ENI type. 流量镜像目的不支持所输入的托管弹性网卡类型。
400 OperationDenied.InvalidSourceBondEniType The traffic mirroring source does not support the entered bond ENI type. 流量镜像源不支持所输入的托管弹性网卡类型。
400 OperationDenied.TargetTypeNotSupportTrafficMirrorFullPacket The traffic mirror session target type does not support the feature of mirroring source full packet. 当前流量镜像会话的目的类型不支持完整报文镜像功能。
400 OperationDenied.TrafficMirrorSessionSourceFullPacketNotSupport The traffic mirror session does not support the feature of mirroring source full packet. 流量镜像当前不支持完整报文镜像功能,TrafficMirrorSourceTruncateMode只能设置为0,即默认模式。
400 QuotaExceeded.SessionNumPerTarget The quota of the number of traffic mirror sessions per target is exceeded.
400 OperationDenied.NotSupportBondEniAsTrafficMirrorSource The operation is not allowed because bond eni cannot be the source of traffic mirror. 不允许托管网卡作为流量镜像的源.
400 IncorrectStatus.TrafficMirrorSessionTarget The status of the target of the traffic mirror session is incorrect. 流量镜像会话的目的的状态不正确。
404 ResourceNotFound.GatewayLoadBalancerEndpoint GatewayLoadBalancerEndpoint instance not found. 未找到GatewayLoadBalancerEndpoint实例。

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情