Creates a filter for traffic mirroring.

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 the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateTrafficMirrorFilter

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

TrafficMirrorFilterDescription String No this is a filter.

The description of the filter. The description must be 2 to 256 characters in length. The description must start with a letter but cannot start with http:// or https://.

TrafficMirrorFilterName String No abc

The name of the filter.

The name must be 2 to 128 characters in length and can contain digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter but cannot start with http:// or https://.

ClientToken String No 123e4567-e89b-12d3-a456-426655440000

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 the value is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length.

Note If you do not set this parameter, the system automatically uses RequestId as ClientToken. RequestId may be different for each API request.
DryRun Boolean No false

Specifies whether to check the request without performing the operation. Valid values:

  • true: checks the request but does not create the filter. The system checks the required parameters, request syntax, and limits. If the request fails the check, an error message is returned. If the request passes the check, the DryRunOperation error code is returned.
  • false: sends the request. If the request passes the check, a 2xx HTTP status code is returned and the filter is created. This is the default value.
RegionId String Yes cn-hongkong

The ID of the region to which the mirrored traffic 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.

IngressRules.N.Action String No accept

The action of the inbound rule. Valid values:

  • accept: collects network traffic.
  • drop: does not collect network traffic.
IngressRules.N.SourceCidrBlock String No 10.0.0.0/24

The source CIDR block of the inbound traffic.

IngressRules.N.Protocol String No TCP

The transport protocol that is used by the inbound traffic to be mirrored. Valid values:

  • ALL: all protocols
  • ICMP: ICMP
  • TCP: TCP
  • UDP: UDP
IngressRules.N.DestinationPortRange String No 80/120

The destination port range of the inbound traffic. Valid values for a port: 1 to 65535. Separate the first port and the last port with a forward slash (/). Examples: 1/200 and 80/80.

Note If you set IngressRules.N.Protocol to ALL or ICMP, you do not need to specify this parameter. In this case, all ports are available.
IngressRules.N.Priority Integer No 1

The priority of the inbound rule. A smaller value specifies a higher priority.

The maximum value of N is 10. You can configure up to 10 inbound rules for a filter.

IngressRules.N.DestinationCidrBlock String No 10.0.0.0/24

The destination CIDR block of the inbound traffic.

IngressRules.N.SourcePortRange String No 80/120

The source port range of the inbound traffic. Valid values for a port: 1 to 65535. Separate the first port and the last port with a forward slash (/). Examples: 1/200 and 80/80.

Note If you set IngressRules.N.Protocol to ALL or ICMP, you do not need to specify this parameter. In this case, all ports are available.
EgressRules.N.Action String No accept

The action of the outbound rule. Valid values:

  • accept: collects network traffic.
  • drop: does not collect network traffic.
EgressRules.N.SourceCidrBlock String No 10.0.0.0/24

The source CIDR block of the outbound traffic.

EgressRules.N.Protocol String No TCP

The transport protocol that is used by the outbound traffic to be mirrored. Valid values:

  • ALL: all protocols
  • ICMP: ICMP
  • TCP: TCP
  • UDP: UDP
EgressRules.N.DestinationPortRange String No 22/40

The destination port range of the outbound traffic. Valid values for a port: 1 to 65535. Separate the first port and the last port with a forward slash (/). Examples: 1/200 and 80/80. You cannot set this parameter to only -1/-1, which specifies all ports.

Note If you set EgressRules.N.Protocol to ALL or ICMP, you do not need to specify this parameter. In this case, all ports are available.
EgressRules.N.Priority Integer No 1

The priority of the outbound rule. A smaller value specifies a higher priority.

The maximum value of N is 10. You can configure up to 10 outbound rules for a filter.

EgressRules.N.DestinationCidrBlock String No 10.0.0.0/24

The destination CIDR block of the outbound traffic.

EgressRules.N.SourcePortRange String No 22/40

The source port range of the outbound traffic. Valid values for a port: 1 to 65535. Separate the first port and the last port with a forward slash (/). Examples: 1/200 and 80/80. You cannot set this parameter to only -1/-1, which specifies all ports.

Note If you set EgressRules.N.Protocol to ALL or ICMP, you do not need to specify this parameter. In this case, all ports are available.

Response parameters

Parameter Type Example Description
TrafficMirrorFilterId String tmf-j6cmls82xnc86vtpe****

The ID of the filter.

RequestId String 28DB147D-217B-43E8-9E94-A3F6837DDC8A

The ID of the request.

Examples

Sample request

http(s)://[Endpoint]/?Action=CreateTrafficMirrorFilter
&TrafficMirrorFilterDescription=this is a filter.
&TrafficMirrorFilterName=abc
&ClientToken=123e4567-e89b-12d3-a456-426655440000
&DryRun=false
&IngressRules=[{"Action":"accept","SourceCidrBlock":"10.0.0.0/24","Protocol":"TCP","DestinationPortRange":"80/120","Priority":1,"DestinationCidrBlock":"10.0.0.0/24","SourcePortRange":"80/120"}]
&EgressRules=[{"Action":"accept","SourceCidrBlock":"10.0.0.0/24","Protocol":"TCP","DestinationPortRange":"22/40","Priority":1,"DestinationCidrBlock":"10.0.0.0/24","SourcePortRange":"22/40"}]
&RegionId=cn-hongkong
&Common request parameters

Sample responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateTrafficMirrorFilterResponse>
    <TrafficMirrorFilterId>tmf-j6cmls82xnc86vtpe****</TrafficMirrorFilterId>
    <RequestId>28DB147D-217B-43E8-9E94-A3F6837DDC8A</RequestId>
</CreateTrafficMirrorFilterResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "TrafficMirrorFilterId" : "tmf-j6cmls82xnc86vtpe****",
  "RequestId" : "28DB147D-217B-43E8-9E94-A3F6837DDC8A"
}

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 QuotaExceeded.TrafficMirrorFilter The maximum number of traffic image filters is exceeded. The error message returned because the number of filters has reached the upper limit.
400 DuplicatedParam.Priority The specified priority conflicts with the existing priority. The error message returned because the specified priority is the same as an existing one.
400 UnsupportedRegion The feature is not supported in current region. The error message returned because this feature is not supported in the current region.

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