Is it possible to distribute spike arrest value based on different query parameters within same proxy?
Solved! Go to Solution.
Yes, you can configure multiple spike arrest policies for different query parameters in Apigee Edge.
To do this, you would first create the spike arrest policies in the Apigee Edge UI or using the Apigee Edge API. Then you would apply the policies to the relevant API proxies or endpoints.
To add a spike arrest policy to a preflow, you would typically add it to the ProxyEndpoint or TargetEndpoint preflow section in the API proxy's XML configuration file. However, instead of adding a single spike arrest policy to the preflow, you can add multiple spike arrest policies by defining them with different names and referencing them in the flow section using a condition.
For example, suppose you have two spike arrest policies defined, "spike-arrest-1" and "spike-arrest-2", that limit the number of requests per minute for different query parameters. You could add them to a ProxyEndpoint preflow like this:
<ProxyEndpoint name="my-proxy">
<PreFlow>
<Request>
<Step>
<Name>spike-arrest</Name>
<Condition>(request.queryparam.param1 != null)</Condition>
<Properties>
<Property name="identifier">param1</Property>
<Property name="rate">1pm</Property>
</Properties>
</Step>
<Step>
<Name>spike-arrest</Name>
<Condition>(request.queryparam.param2 != null)</Condition>
<Properties>
<Property name="identifier">param2</Property>
<Property name="rate">5pm</Property>
</Properties>
</Step>
</Request>
</PreFlow>
...
</ProxyEndpoint>
In this example, the first spike arrest policy ("spike-arrest-1") is applied when the "param1" query parameter is present in the request, and the second policy ("spike-arrest-2") is applied when the "param2" query parameter is present. The "identifier" property specifies the query parameter to track, and the "rate" property specifies the maximum number of requests per minute.
You can adjust the conditions, identifier values, and rate limits to fit your specific use case.