Updated on 2024-10-18 GMT+08:00

Traffic Mirroring

APIG mirrors source backend requests to images for traffic analysis and statistics without affecting online services.

Usage Guidelines

  • You have understood the guidelines for policy creation and API binding.
  • The response to the image request will be ignored.
  • The body size of an image request is defaulted to 12 MB and can be configured via the parameter request_body_size. A larger request body size indicates greater performance loss. Exercise caution when performing this operation.
  • Not supported for APIs with a Mock backend.

Configuration Parameters

Table 1 Configuration parameters

Parameter

Description

Protocol

The image request protocol. It must be the same as the user's image service protocol.

Image Address

The image service address, which consists of the IP address/domain name and port number. Max: 255 characters. Format: Host name:Port number. Example: xxx.xxx.xxx:7443. If the port number is not specified, the default HTTPS port 443 or the default HTTP port 80 is used.

Image URI

URI for HTTP/HTTPS image requests. Max. 512 characters, including special characters (*%-_.). Defaults to the original path of the bound API if not specified.

Concatenation

Specifies how to concatenate the image request path.

Replace: Uses the specified image request path.

Prefix: Combines the specified image request path and the source request URI.

Sampling Ratio

Sampling ratio of image requests. Range: 0.00001–1. Default: 1 (full sampling)

For example, if there are 1,000 API requests and the sampling ratio is 0.1, 100 requests will be sampled.

Timeout (ms)

Image request timeout. Unit: ms. Default: 5,000 ms.

Mirror Request Body

Mirrors the body of client requests. Enabled by default.

Example Script

{
  "protocol": "HTTPS",
  "host": "X.X.X.X",
  "sample_ratio": 1,
  "timeout": 5000,
  "mirror_request_body_enabled": true,
  "path": "/ab",
  "path_concat_mode": "replace"
}