Quota identifier across different Policies

Hello. I have a quota chain whose parameters are set dynamically by preliminary JS policy. The JS policy sets the required values according to matched rules (more than 30). All parameters are different. Using over 30 Quotas (each quota per rule) complicates maintenance. When I make a request with condition "A" one rule is triggered and it sets the set of parameters for Quota-1 (<Identifier ref="ident-1"/> <Allow countRef="lim-1"/>) Then new request with conditions "A" and "B" are sets the set of parameters for Quota-1 and Quota-2 (<Identifier ref="ident-1"/> <Allow countRef="lim-1"/>)(<Identifier ref="ident-2"/> <Allow countRef="lim-2"/>) But when I make a request with only condition "B" it sets params for Quota-1 but the Quota counter starts with "0" it would be better if counter values were reused.
Is it possible to use relevant Identifier and allowsCount across Quota policies?


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SharedFlow name="default">
    <Step>
        <Name>KVM-ExtractValues</Name>
    </Step>
    <Step>
        <Name>JS-SeparateValues</Name>
    </Step>
    <Step>
        <Name>Quota-1</Name>
    </Step>
        <Step>
        <Name>Quota-2</Name>
    </Step>
</SharedFlow>
 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Quota continueOnError="true" enabled="true" name="Quota-1">
<DisplayName>Quota-1</DisplayName>
<Identifier ref="ident-1"/>
<Allow countRef="lim-1"/>
<Interval>1</Interval>
<TimeUnit>minute</TimeUnit>
<Distributed>true</Distributed>
<Synchronous>true</Synchronous>
</Quota>
 
 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Quota continueOnError="true" enabled="true" name="Quota-2">
<DisplayName>Quota-2</DisplayName>
<Identifier ref="ident-2"/>
<Allow countRef="lim-2"/>
<Interval>1</Interval>
<TimeUnit>minute</TimeUnit>
<Distributed>true</Distributed>
<Synchronous>true</Synchronous>
</Quota>
 
0 3 149
3 REPLIES 3

Today in Apigee, There is no way to specify multiple Quota policies and have them reference the same Identifier and counter bucket. Of course you can specify the same Identifier element, and reference the same variable. But internally the Quota policy adds the policy name to the Identifier, so the effective identifier is a compound value that ALWAYS includes the policy name. Therefore two distinct policies will always use distinct effective identifiers.

There is an outstanding feature request in the backlog, asking for an enhancement of the Quota policy that would allow you to do the thing you want to do.  The internal reference is b/149229963 . I suggest that you connect with your customer account team (your Customer Engineer) and express an interest in getting this enhancement implemented. That will help raise the priority in getting the work done. 

cc: @kurtkanaskie 

If I understand your use case you want to apply quota separately for Condition A and Condition B independently of each other and only when Conditions A or B exist but do nothing when either condition is absent.

Then perhaps you can merely add conditions for each Quota:

<SharedFlow name="default">
    <Step>
        <Name>KVM-ExtractValues</Name>
    </Step>
    <Step>
        <Name>JS-SeparateValues</Name>
    </Step>
    <Step>
        <Condition>condition_A = true</Condition>
        <Name>Quota-1</Name>
    </Step>
    <Step>
        <Condition>condition_B = true</Condition>
        <Name>Quota-2</Name>
    </Step>
</SharedFlow>

In the docs for Quota Policy - Identifier there is a reference to How does the Edge quota policy work when no identifier is specified?  So in your case when a condition is absent (with only condition "B") the quota policy in Quota-1 counts on a default counter.

Dino's point it important also, the Quota policy is scoped to the proxy in which it executes, even if it uses the same identifier value. Therefore, you can't count across multiple proxies, you'd have to use a separate proxy that each of the multiple proxies callout (e.g. chain) to, but this gets complex, hence the feature request.

@dchiesa1 and @kurtkanaskie thanks for your comment. Dino got me right. One clarification regarding my issue

1.png2.png