Creates a traffic mirror session.
Usage notes
CreateTrafficMirrorSession is an asynchronous operation. After a request is sent, the system returns a request ID and runs the task in the background. You can call the ListTrafficMirrorSessions operation to query the status of the task:
- If the traffic mirror session is in the Creating state, the traffic mirror session is being created.
- If the traffic mirror session is in the Created state, the traffic mirror session is created.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | CreateTrafficMirrorSession | The operation that you want to perform. Set the value to CreateTrafficMirrorSession. |
TrafficMirrorSessionDescription | String | No | This is a trafficmirrorsession. | The description of the traffic mirror session. The description must be 1 to 256 characters in length, and cannot start with |
TrafficMirrorSessionName | String | No | test | The name of the traffic mirror session. The name must be 1 to 128 characters in length and cannot start with |
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 token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters. Note If you do not specify this parameter, the system automatically uses the request ID as the client token. The request ID may be different for each request. |
DryRun | Boolean | No | false | Specifies whether to perform only a dry run, without performing the actual request. Valid values:
|
TrafficMirrorTargetId | String | Yes | eni-j6c8znm5l1yt4sox**** | The ID of the traffic mirror destination. You can specify only an elastic network interface (ENI) or a Server Load Balancer (SLB) instance as a traffic mirror destination. |
TrafficMirrorTargetType | String | Yes | NetworkInterface | The type of the traffic mirror destination. Valid values:
|
TrafficMirrorFilterId | String | Yes | tmf-j6cmls82xnc86vtpe**** | The ID of the traffic mirror filter. |
VirtualNetworkId | Integer | No | 1 | The VXLAN network identifier (VNI). Valid values: 0 to 16777215. You can use VNIs to identify mirrored traffic from different sessions at the traffic mirror destination. You can specify a custom VNI or use a random VNI allocated by the system. If you want the system to randomly allocate a VNI, do not enter a value. |
Priority | Integer | Yes | 1 | Specify 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 by using the same account. |
Enabled | Boolean | No | false | Specifies whether to enable the traffic mirror session. Valid values:
|
PacketLength | Integer | No | 1500 | The maximum transmission unit (MTU). Valid values: 64 to 9600. Default value: 1500. |
TrafficMirrorSourceIds.N | String | No | eni-j6c2fp57q8rr47rp**** | The ID of the traffic mirror source. You can specify only an ENI as the traffic mirror source. The default value of N is 1, which means that you can add only one traffic mirror source to a traffic mirror session. |
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. |
ResourceGroupId | String | No | rg-bp67acfmxazb4ph**** | The ID of the resource group to which the mirrored traffic belongs. |
Tag.N.Key | String | No | FinanceDept | The key of tag N to add to the resource. You can specify at most 20 tag keys. The tag key cannot be an empty string. The tag key can be at most 128 characters in length. It cannot start with |
Tag.N.Value | String | No | FinanceJoshua | The value of tag N to add to the resource. You can specify at most 20 tag values. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot start with |
Response parameters
Parameter | Type | Example | Description |
TrafficMirrorSessionId | String | tms-j6ce5di4w7nvigfjz**** | The ID of the traffic mirror session. |
RequestId | String | 0ED8D006-F706-4D23-88ED-E11ED28DCAC0 | The request ID. |
ResourceGroupId | String | rg-bp67acfmxazb4ph**** | The ID of the resource group to which the mirrored traffic belongs. |
Examples
Sample requests
http(s)://[Endpoint]/?Action=CreateTrafficMirrorSession
&TrafficMirrorSessionDescription=This is a trafficmirrorsession.
&TrafficMirrorSessionName=test
&ClientToken=0c593ea1-3bea-11e9-b96b-88e9fe63****
&DryRun=false
&TrafficMirrorTargetId=eni-j6c8znm5l1yt4sox****
&TrafficMirrorTargetType=NetworkInterface
&TrafficMirrorFilterId=tmf-j6cmls82xnc86vtpe****
&VirtualNetworkId=1
&Priority=1
&Enabled=false
&PacketLength=1500
&TrafficMirrorSourceIds=["eni-j6c2fp57q8rr47rp****"]
&RegionId=cn-hongkong
&ResourceGroupId=rg-bp67acfmxazb4ph****
&Tag=[{"Key":"FinanceDept","Value":"FinanceJoshua"}]
&Common request parameters
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateTrafficMirrorSessionResponse>
<TrafficMirrorSessionId>tms-j6ce5di4w7nvigfjz****</TrafficMirrorSessionId>
<RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
<ResourceGroupId>rg-bp67acfmxazb4ph****</ResourceGroupId>
</CreateTrafficMirrorSessionResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"TrafficMirrorSessionId" : "tms-j6ce5di4w7nvigfjz****",
"RequestId" : "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
"ResourceGroupId" : "rg-bp67acfmxazb4ph****"
}
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 disabled. |
400 | DuplicatedParam.SourceInstanceIds | The parameter of source instance IDs contains duplicate values. | The error message returned because duplicate values are set for the TrafficMirrorSourceIds.N parameter. |
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 %s is not found. | The specified NetworkInterface %s 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 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 traffic 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 of 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. |
400 | OperationDenied.ClassicSLB | The operation is not allowed because of ClassicSLB. | You cannot perform the operation on a Classic Load Balancer (CLB) instance. |
400 | ResourceNotFound.TargetInstance | The specified target instance for traffic mirroring is not found. | The specified traffic mirror destination does not exist. |
400 | QuotaExceeded.SourceNumPerTarget | The maximum number of traffic mirror sources for a target is exceeded. | The number of traffic mirror sources associated with the traffic mirror destination exceeds the upper limit. |
For a list of error codes, visit the API Error Center.