Proxy Mirror
APIG mirrors source backend requests to images for traffic analysis and statistics without affecting online services.
Usage Guidelines
- 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.
Prerequisites
- An API can be bound with only one policy of the same type.
- Policies are independent of APIs. A policy takes effect for an API only after they are bound to each other. When binding a policy to an API, you must specify an environment where the API has been published. The policy takes effect for the API only in the specified environment.
- After you bind a policy to an API, unbind the policy from the API, or update the policy, you do not need to publish the API again.
- Taking an API offline does not affect the policies bound to it. The policies are still bound to the API if the API is published again.
- Policies that have been bound to APIs cannot be deleted.
Creating a Proxy Mirror Policy
- Go to the APIG console.
- Select a dedicated gateway at the top of the navigation pane.
- In the navigation pane, choose API Management > API Policies.
- On the Policies tab, click Create Policy.
- On the Select Policy Type page, select Proxy Mirror in the Plug-ins area.
- Set the policy information.
Table 1 Proxy mirror parameters Parameter
Description
Name
Enter a policy name. Using naming rules facilitates future search.
Type
Fixed as Proxy Mirror.
Description
Description about the plug-in.
Policy Content
Content of the plug-in, which can be configured in a form or using a script.
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.
- Click OK.
- To clone this policy, click Clone in the Operation column.
The name of a cloned policy cannot be the same as that of any existing policy.
- After the policy is created, perform the operations described in Binding the Policy to APIs for the policy to take effect for the API.
- To clone this policy, click Clone in the Operation column.
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" }
Binding the Policy to APIs
- Click a policy name to go to the policy details page.
- Select an environment and click Select APIs.
- Select the API group, environment, and required APIs.
APIs can be filtered by API name or tag. The tag is defined during API creation.
- Click OK.
- If an API no longer needs this policy, click Unbind in the row that contains the API.
- If there are multiple APIs that no longer need this policy, select these APIs, and click Unbind above the API list. You can unbind a policy from a maximum of 1000 APIs at a time.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot