apisix
                                
                                 apisix copied to clipboard
                                
                                    apisix copied to clipboard
                            
                            
                            
                        help request: limit-count plugin
Description
Hi, we have a use case where we would like to use APISix to provide a prepaid way to access our API. e.g. a client would subscribe for 12 months or 1,000,000 API calls and it looks like the limit-count plugin supports this. I have two questions though.
Does it make this distinction per customer? We are anticipate using the X-API-Key for authentication and would be ideal if we could group by this.
Is there a way that we can expose the usage count for the client via a GET call so they can assess and budget their usage?
Thanks in advance
Environment
- APISIX version (run apisix version):
- Operating system (run uname -a):
- OpenResty / Nginx version (run openresty -Vornginx -V):
- etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run luarocks --version):
Does it make this distinction per customer?
We can set the key to be $consumer_name to distinguish the customer, e.g.:
    "plugins": {
        "limit-count": {
            "count": 2,
            "time_window": 60,
            "rejected_code": 503,
            "key": "$consumer_name"
        }
    },
for more details, ref: https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/limit-count.md#attributes
X-API-Key is used for the admin API of APISIX. It is not related to customs and should not be used to count requests generated by customs.
Is there a way that we can expose the usage count for the client via a GET call so they can assess and budget their usage?
None. But you can add this functionality based on open source plugins.
Thanks @tzssangglass , much appreciated. Do you know of any specific plugins that support the functionality required?
@MalWalters By the way, you should be careful about the quota sharing; by default, the quote is calculated per instance. It's not shared among the cluster.
Also, use $consumer_name as the key doesn't allow you to configure different quotas for different consumers.
Thanks @tzssangglass , much appreciated. Do you know of any specific plugins that support the functionality required?
You need to implement such functionality yourself.
@tokers thanks for the heads up. That should be OK we'd be looking at going with one instance for the POC and load test to assess performance limitations.
@MalWalters : We met the same requirement, how do you make it finally?
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.