AHAS active degradation rules allow you to degrade specific interfaces. When an interface is degraded, it triggers a custom degradation behavior, such as returning a predefined response, instead of executing its original logic. This topic describes how to create an active degradation rule.
Prerequisites
Connect your application to AHAS Application Protection. For instructions, see Connect your application.
Usage notes
Active degradation rules support the following scenarios:
- Active degradation rules are supported only by the AHAS Sentinel Java SDK or agent version 1.8.4 and later.
- Degradation behavior settings currently apply only to the built-in Web instrumentation provided by AHAS, including adapters for Servlet, Spring Web, and Spring Cloud Gateway. Other instrumentation types will continue to use their original fallback logic. For more information, see Configure logic after a rule is triggered.
- If you register a block handler for custom fallback logic in your code, it overrides the degradation behavior that you configure for an active degradation rule in the console.
- Active degradation rules are not supported for applications that use SDKs for other programming languages.
Create an active degradation rule
- Log on to the AHAS console. In the upper-left corner of the page, select a region.
- In the left-side navigation pane, choose .
- On the Application Protection page, click the card for your application.
- In the left-side navigation pane, click Interface Details. On the Interface Details page, click the
or
icon in the upper-right corner of a resource card. In the Manage Rules dialog box, select the tab for your target plan, click the Degradation Rule tab, and then click New Active Degradation Rule in the upper-right corner of the tab. - In the dialog box that appears, configure the following parameters and then click Create.
Parameter Description Example Interface name The name of the resource to which this rule applies. This name must match the resource name shown on the monitoring page, which is the value passed through instrumentation. /hello Degradation behavior The behavior of the interface call when this degradation rule is enabled. The Default Behavior option corresponds to the Web configuration in Application Settings > Basic Settings > Module Adapter Settings. For more information, see Configure module adapters.
Note Currently, this degradation behavior applies only to the built-in Web instrumentation provided by AHAS.Default Behavior To add a new behavior, click New Behavior, configure the following parameters, and then click Add. For more information, see Configure Web behaviors.
Parameter Description Example Behavior name The name of the behavior. The name can be up to 128 characters long and must be unique within the application. Test behavior Resource type Only the Web type is supported. Web Web throttling policy The behavior of a web interface when a rule is triggered. The following policies are supported: - Custom Response: You must set the HTTP response status code, response content format, and response body. When a rule is triggered for a web interface, the system returns a custom response.
- Redirect to a Specific URL: You must specify a redirect URL. When a rule is triggered for a web interface, the system redirects the request to the specified URL.
Custom Response HTTP response status code Default value: 429. This parameter is required when the Web throttling policy is set to Custom Response. 429 Content-type The format of the response content, such as TEXT or JSON. This parameter is required when the Web throttling policy is set to Custom Response. JSON HTTP response body The response body to return when a rule is triggered for the web interface. This parameter is required when the Web throttling policy is set to Custom Response. {"message": "blocked oops"} Redirect URL The URL to which the system redirects requests when a rule is triggered. This parameter is required when the Web throttling policy is set to Redirect to a Specific URL. Note Redirection is handled by returning an HTTP 302 status code. This method works for pages rendered and returned by a backend service. However, it is not effective for pages where the frontend uses an AJAX request to fetch and render data.http://ahas.console.aliyun.com