Creates a traffic mirror session.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates a sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateTrafficMirrorSession

The operation that you want to perform. Set the value to CreateTrafficMirrorSession.

Priority Integer Yes 1

The priority of the traffic mirror session. Valid values: 1 to 32766.

A smaller value indicates a higher priority. You cannot specify the same priority for traffic mirror sessions that are created in the same region with the same Alibaba Cloud account.

RegionId String Yes cn-hongkong

The ID of the region to which the traffic mirror session belongs. You can call the DescribeRegions operation to query the most recent region list. For more information about regions that support traffic mirroring, see Overview of traffic mirroring.

TrafficMirrorFilterId String Yes tmf-j6cmls82xnc86vtpe****

The ID of the filter.

TrafficMirrorSourceIds.N RepeatList Supported eni-j6c2fp57q8rr47rp****

The ID of the mirror source. You can specify only an elastic network interface (ENI) as the mirror source. The default value of N is 1, which indicates that you can add only one mirror source to a traffic mirror session.

TrafficMirrorTargetId String Yes eni-j6c8znm5l1yt4sox****

The ID of the mirror destination. You can specify only an ENI or a Server Load Balancer (SLB) instance as a mirror destination.

TrafficMirrorTargetType String Yes NetworkInterface

The type of the mirror destination.

  • NetworkInterface: an ENI
  • SLB: an internal-facing SLB instance
TrafficMirrorSessionDescription String No This is a trafficmirrorsession.

The description of the traffic mirror session. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

TrafficMirrorSessionName String No test

The name of the traffic mirror session. The name must be 2 to 128 characters in length and can contain digits, underscores (_), and hyphens (-). It must start with a letter.

ClientToken String No 0c593ea1-3bea-11e9-b96b-88e9fe63****

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that it is unique among different requests. ClientToken can contain only ASCII characters. It cannot exceed 64 characters in length.

DryRun Boolean No false

Specifies whether to precheck this request. Valid values:

  • true: only checks the API request. The mirror source is not created. The system checks the required parameters, request format, and limits. If the request fails the precheck, the corresponding error code is returned. If the request passes the precheck, the DryRunOperation error code is returned.
  • false: sends the request. After the request passes the precheck, the traffic mirror session is created.
VirtualNetworkId Integer No 1

The VXLAN network identifier (VNI) that is used to distinguish different mirrored traffic. Valid values: 0 to 16777215. You can specify VNIs for the traffic mirror destination to identify mirrored traffic from different sessions. If you do not specify a VNI, the system randomly allocates a VNI. If you want the system to randomly allocate a VNI, ignore this parameter.

Enabled Boolean No false

Specifies whether to enable traffic mirror sessions.

  • false (default): no
  • true: yes
PacketLength Integer No 1500

The maximum transmission unit. Set the value to 1500 or ignore this parameter.

Response parameters

Parameter Type Example Description
RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

The ID of the request.

TrafficMirrorSessionId String tms-j6ce5di4w7nvigfjz****

The ID of the traffic mirror session.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateTrafficMirrorSession
&Priority=1
&RegionId=cn-hongkong
&TrafficMirrorFilterId=tmf-j6cmls82xnc86vtpe****
&TrafficMirrorSourceIds.1=eni-j6c2fp57q8rr47rp****
&TrafficMirrorTargetId=eni-j6c8znm5l1yt4sox****
&TrafficMirrorTargetType=NetworkInterface
&<Common request parameters>

Sample success responses

XML format

<CreateTrafficMirrorSessionResponse>
  <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
  <TrafficMirrorSessionId>tms-j6ce5di4w7nvigfjz****</TrafficMirrorSessionId>
</CreateTrafficMirrorSessionResponse>

JSON format

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

Error codes

HttpCode Error code Error message Description
400 IncorrectBusinessStatus.TrafficMirror The business status of traffic mirror is incorrect. The error message returned because the mirrored traffic is in an invalid state.
400 OptInRequired.TrafficMirror You need to subscribe to the traffic mirror service first. The error message returned because traffic mirroring is not enabled.
400 DuplicatedParam.SourceInstanceIds The parameter of source instance IDs contains duplicate values. the id parameter of the traffic mirror source instance contains duplicate values.
400 OperationDenied.DuplicateRole The network interface must not be the source and the target of traffic mirror sessions at the same time. The error message returned because an ENI cannot be specified as both the source and destination of a traffic mirror session.
400 ResourceNotFound.NetworkInterface The specified resource of network interface is not found. The error message returned because the specified ENI does not exist.
400 ResourceNotFound.EcsInstance The specified resource of ECS instance is not found. The error message returned because the specified Elastic Compute Service (ECS) instance does not exist.
400 ResourceNotFound.Slb The specified resource of SLB is not found. The error message returned because the specified SLB instance does not exist.
400 OperationDenied.SlbNotInVpc The specified SLB is not in any VPC. The error message returned because the specified SLB instance does not belong to a virtual private cloud (VPC).
400 ResourceNotFound.TrafficMirrorFilter The specified resource of traffic mirror filter is not found. The error message returned because the specified filter does not exist.
400 IncorrectStatus.TrafficMirrorFilter The status of traffic mirror filter is incorrect. The error message returned because the specified filter is in an invalid state.
400 OperationDenied.EcsNotSupportTrafficMirror The ECS instance does not support traffic mirroring. The error message returned because the ECS instance does not support traffic mirroring.
400 QuotaExceeded.SessionNum The quota of the number of traffic mirror sessions is exceeded. The error message returned because the number of traffic mirror sessions has reached the upper limit.
400 QuotaExceeded.FilterRelatedSession The quota of the number of traffic mirror sessions related to one filter is exceeded. The error message returned because the number of traffic mirror sessions associated with the filter has reached the upper limit.
400 QuotaExceeded.SourceNumPerSession The quota of the number of traffic mirror sources per session is exceeded. The error message returned because the number of mirror sources associated with a traffic mirror session has reached the upper limit.
400 QuotaExceeded.NetworkInterfaceRelatedSession The quota of the number of traffic mirror sessions related to one network interface is exceeded. The error message returned because the number of traffic mirror sessions associated with an ENI has reached the upper limit.
400 QuotaExceeded.SlbRelatedSession The quota of the number of traffic mirror sessions related to one SLB is exceeded. The error message returned because the number traffic mirror sessions associated with an SLB instance has reached the upper limit.
400 UnsupportedRegion The feature is not supported in current region. The error message returned because this feature is not supported in the current region.
400 InvalidLoadBalancerId.NotFound The specified resource of load balancer is not found. The error message returned because the specified SLB instance does not exist.
400 OperationDenied.FreeNetworkInterface The network interface is not attached to any ECS instance. The error message returned because the specified ENI is not associated with an ECS instance.

For a list of error codes, visit the API Error Center.