-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to check current client rate limit usage and limits during runtime? #152
Comments
@whentotrade This may not be exactly what you are looking for but if you are using Application Insights you can have it listen for the ILogger Information messages from the rate-limiting middleware. This can be done through appsettings.json. e.g. "Logging": { In this example, we are telling Application Insights to record Warning (and above), except for when it comes to AspNetCoreRateLimit where we record Information (and above). This lets you see the failure in Application Insights with a trace explaining why the request was blocked. I.e. what rule was applied. |
thanks for the response, but yes, it is not what I am looking for. Using API from a customer perspective, you should have an option to see what is your current consumed api call amount and the still available counts until your limits are reached. Right now, we can not get this information - would be a nice enhancement |
Did one work around: When you make requests to end point, Rate limit will add one key in redis which will have counter value. To get those counter you need to first create key for particular client $"{options.RateLimitCounterPrefix}{requestIdentity.ClientId}{rule.Period}" + $"{requestIdentity.HttpVerb}_{requestIdentity.Path}"; Example : crlc_client1_1d_get_/api/values Now you need to hash this key using :
Using above key you can find count value for particular endpoint. Let me know if you need your help |
Question/Request only:
Is there a way to read the current used rate-limit counter per time-limit rule and set rate limit for a given client / client id?
E.g. showing a user the applied limits per endpoint and the already used count against these limits? As this is done with most API based services where you can see the limit per client used count.
I can make a call against each endpoint to check that? But is there a way to read this information per client from the internals somewhere? Any hint would be welcome.
The text was updated successfully, but these errors were encountered: