How do I get Quota working in Microgateway?

Not applicable

I have configured the Quota plugin and restarted the gateway. When I start things up I see the Quota information downloaded from Edge product (10 per minute), but the fault doesn't fire. I have not configured any settings in the config file other than to use the quota plugin as per instructions. I've tried the API call using both Bearer and API Key. The Spike arrest policy works OK.

Related thread: Getting past "verify" step.

Suggestions?

Solved Solved
1 8 1,467
1 ACCEPTED SOLUTION

Hi Kurt,

I just tried myself, and the quota worked. You've probably done these steps, but here's what I did:

1. Set up EM according to the Setup and Configure instructions.

2. In the Product I created for my edgemicro_* proxy, I set the Quota to 5 calls per minute.

3. Added quota to the sequence in agent/config/default.yaml:

sequence:
   - oauth
   - quota

4. Restarted the agent and Edge Micro.

5. Called the API 5 times in quick succession and got the fault:

curl "http://localhost:8000/em-weather-111/forecastrss?w=12797282" -H "x-api-key: Arv0WtUiZ3SXGrsvcsJtYf3lrzKQJIAG"
{"message":"exceeded quota","status":403}

Does this help?

View solution in original post

8 REPLIES 8

Hi Kurt,

I just tried myself, and the quota worked. You've probably done these steps, but here's what I did:

1. Set up EM according to the Setup and Configure instructions.

2. In the Product I created for my edgemicro_* proxy, I set the Quota to 5 calls per minute.

3. Added quota to the sequence in agent/config/default.yaml:

sequence:
   - oauth
   - quota

4. Restarted the agent and Edge Micro.

5. Called the API 5 times in quick succession and got the fault:

curl "http://localhost:8000/em-weather-111/forecastrss?w=12797282" -H "x-api-key: Arv0WtUiZ3SXGrsvcsJtYf3lrzKQJIAG"
{"message":"exceeded quota","status":403}

Does this help?

As soon as I saw your sequence, I figured oauth had to be before quota, makes sense now that I think about it.

Thanks!

Not applicable

Ah, but I see this in the docs at: http://docs.apigee.com/microgateway/content/using-plugins#Using the quota plugin

3. Add the quota plugin to the sequence element. It's a good idea to place quota first in the sequence list. That way, no additional processing will occur if the quota is exceeded.

@kurtkanaskie Thanks for catching that -- I think it is a doc bug -- I'll investigate and make the necessary corrections and update here when I'm done.

@kurtkanaskie Thanks again. The doc has been fixed to make it clear that to use the quota plugin, you must enable token or key authentication using the oauth plugin, and the oauth plugin must precede the quota plugin in the sequence, like this:

sequence:
   - oauth
   - quota

Not applicable

How can I use it without "Product" ? I switched off "Authorization" by advice

default.yaml

...

plugins: dir: ../plugins sequence: - analytics - quota

headers: x-forwarded-for: true x-forwarded-host: true x-request-id: true x-response-time: true via: true oauth: allowNoAuthorization: true allowInvalidAuthorization: true

....

Added "quota" plugin, added "Quota 1 request every 1 minute" to product and I think that "quota" doesn't work. I can call my API, more than 1 request every 1 minute.

prabhat
Participant V

You can not use it without Product. If you want to have something custom then you would have to write your plugin.

Also pls keep in mind that Quota is an approximate quota since you don't wan to synch with Edge for every API call.

Thank you for your answer. Regarding micro gateway, oauth, quota & my question.

As I understood, I can create "product" for each customer for authorization and can use quota (rights) for a each "product". Or a one "product" for all customers. Right?

After that I can get statistic information for a different "products". Right?

Can I use "product" and my authorization at the same time?