You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/05/04 07:45:09 UTC

[GitHub] [apisix] hzbd opened a new issue #4124: request help: how to get current limit count from redis cache?

hzbd opened a new issue #4124:
URL: https://github.com/apache/apisix/issues/4124


   ### Issue description
   
   > https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/limit-count.md
   
   **1. If I use redis to store limit count cache, how to get the current value of count by admin? Is there an admin api interface to get this or do I need to get it from redis by myself?**
   
   **2. How is the key value naming rule of limit count defined?**
   ![image](https://user-images.githubusercontent.com/3000843/115983395-62d8f400-a5d3-11eb-9595-15a25bcc366d.png)
   
   
   ### Environment
   
   dashboard]# apisix version
   /usr/local/openresty/luajit/bin/luajit /usr/local/apisix/apisix/cli/apisix.lua version
   2.4
   
   dashboard]# uname -a
   Linux xxx 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
   
   dashboard]# ./manager-api -v
   Version : 2.5
   GitHash : 5c95d97
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
tokers commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826299034






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826316078






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd closed issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd closed issue #4124:
URL: https://github.com/apache/apisix/issues/4124


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd closed issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd closed issue #4124:
URL: https://github.com/apache/apisix/issues/4124


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
tokers commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826324642


   We may add these information by server-info plugin.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826316078


    hi @tokers 
   
   We want to periodically obtain the current `limit count` remaining amount, which is displayed in dashboard. And plan to use limit count as billing credentials, such as 100,000 calls / month.
   
   ![image](https://user-images.githubusercontent.com/3000843/115993204-5d47d200-a604-11eb-96ff-fe1aa812f6d8.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-831746567


   
   ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   
   part 1: common prefix
   part 2: consumer username
   part 3:  ?
   
   Is this part(part 3) a version attribute? Can you help find out where the key generation rules are in the source code?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd edited a comment on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd edited a comment on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-831746567


   ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   ps: this is a screenshot of redis key naming for consumer `limit count`.
   
   part 1: common prefix
   part 2: consumer username
   part 3:  ?
   
   Q1: Is this part(part 3) a version attribute? Can you help find out where the key generation rules are in the source code?
   
   Q2: If it is convenient for a third-party program to directly obtain the consumer's latest limit count value in redis, can we remove part3 and only keep the latest version?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd edited a comment on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd edited a comment on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-831746567


   ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   ps: this is a screenshot of redis key naming for limit count.
   
   part 1: common prefix
   part 2: consumer username
   part 3:  ?
   
   Is this part(part 3) a version attribute? Can you help find out where the key generation rules are in the source code?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826335544


   This is a great project, thanks @tokers @Firstsawyou 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd edited a comment on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd edited a comment on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826316078


    hi @tokers 
   
   We want to periodically obtain the current `limit count` remaining amount, which is displayed in dashboard. And plan to use limit count as billing credentials, such as 100,000 calls / month.
   
   If it is not suitable for this scenario, we will place this function on the application gateway.
   
   ![image](https://user-images.githubusercontent.com/3000843/115993204-5d47d200-a604-11eb-96ff-fe1aa812f6d8.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd edited a comment on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd edited a comment on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-831746567






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Firstsawyou commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826278553


   > 1. If I use redis to store limit count cache, how to get the current value of count by admin? Is there an admin api interface to get this or do I need to get it from redis by myself?
   
   The limit count cache value cannot be obtained through admin api, can you refer to the method here to obtain it.
   
   https://github.com/apache/apisix/blob/681b0bda1625c2d9030489e0c5ef42f688c65156/apisix/plugins/limit-count/limit-count-redis-cluster.lua#L85-L101
   
   https://github.com/apache/apisix/blob/681b0bda1625c2d9030489e0c5ef42f688c65156/apisix/plugins/limit-count.lua#L169
   
   >2.How is the key value naming rule of limit count defined?
   
   This cannot be customized, it is generated according to certain rules.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-833974390


   
   
   
   > > ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   > > ps: this is a screenshot of redis key naming for consumer plugin `limit count` by `consumer_name `
   > > **part 1**: common prefix
   > > **part 2**: consumer username
   > > **part 3**: ?
   > > Q1: Is this part(**part 3**) a version attribute? Can you help find out where the key generation rules are in the source code?
   > > Q2: If it is convenient for a third-party program to directly obtain the consumer's latest limit count value in redis, can we remove **part3** and only keep the latest version(**part1 + part2**)?
   > 
   > That's right, the third part is the version of plugin configuration. Also, it's feasible to customize your key.
   > 
   > Please see http://apisix.apache.org/docs/apisix/plugins/limit-count.
   
   hi,@tokers 
   
   So can we remove the third part? Only keep the latest version (if possible, how to do it?). The version history of the data does not seem to be used in the future, unless it is used for fault tracking.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
tokers commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-833993804


   > > > ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   > > > ps: this is a screenshot of redis key naming for consumer plugin `limit count` by `consumer_name `
   > > > **part 1**: common prefix
   > > > **part 2**: consumer username
   > > > **part 3**: ?
   > > > Q1: Is this part(**part 3**) a version attribute? Can you help find out where the key generation rules are in the source code?
   > > > Q2: If it is convenient for a third-party program to directly obtain the consumer's latest limit count value in redis, can we remove **part3** and only keep the latest version(**part1 + part2**)?
   > > 
   > > 
   > > That's right, the third part is the version of plugin configuration. Also, it's feasible to customize your key.
   > > Please see http://apisix.apache.org/docs/apisix/plugins/limit-count.
   > 
   > hi,@tokers
   > 
   > So can we remove the third part? Only keep the latest version (if possible, how to do it?). The version history of the data does not seem to be used in the future, unless it is used for fault tracking.
   
   Just like what I said above, you can customize the key.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd edited a comment on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd edited a comment on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-831746567


   ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   ps: this is a screenshot of redis key naming for consumer plugin `limit count` by `consumer_name `
   
   part 1: common prefix
   part 2: consumer username
   part 3:  ?
   
   Q1: Is this part(part 3) a version attribute? Can you help find out where the key generation rules are in the source code?
   
   Q2: If it is convenient for a third-party program to directly obtain the consumer's latest limit count value in redis, can we remove part3 and only keep the latest version(part1 + part2)?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
tokers commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826299034


   @hzbd Could you describe the scenario that you're facing to get this count?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd edited a comment on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd edited a comment on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826316078


    hi @tokers 
   
   We want to periodically obtain the current `limit count` remaining amount, which is displayed in dashboard. And plan to use limit count as billing credentials, such as 100,000 calls / month.
   
   If it is not suitable for this scenario, we will place this function on the application gateway.
   
   ![image](https://user-images.githubusercontent.com/3000843/115993204-5d47d200-a604-11eb-96ff-fe1aa812f6d8.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd closed issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd closed issue #4124:
URL: https://github.com/apache/apisix/issues/4124


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
tokers commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-833170088


   > ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   > ps: this is a screenshot of redis key naming for consumer plugin `limit count` by `consumer_name `
   > 
   > **part 1**: common prefix
   > **part 2**: consumer username
   > **part 3**: ?
   > 
   > Q1: Is this part(**part 3**) a version attribute? Can you help find out where the key generation rules are in the source code?
   > 
   > Q2: If it is convenient for a third-party program to directly obtain the consumer's latest limit count value in redis, can we remove **part3** and only keep the latest version(**part1 + part2**)?
   
   That's right, the third part is the version of plugin configuration. Also, it's feasible to customize your key.
   
   Please see http://apisix.apache.org/docs/apisix/plugins/limit-count.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd edited a comment on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd edited a comment on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-831746567


   ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   ps: this is a screenshot of redis key naming for consumer plugin `limit count` by `consumer_name `
   
   part 1: common prefix
   part 2: consumer username
   part 3:  ?
   
   Q1: Is this part(part 3) a version attribute? Can you help find out where the key generation rules are in the source code?
   
   Q2: If it is convenient for a third-party program to directly obtain the consumer's latest limit count value in redis, can we remove part3 and only keep the latest version?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] hzbd edited a comment on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
hzbd edited a comment on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-831746567


   ![image](https://user-images.githubusercontent.com/3000843/116973686-7715a300-acef-11eb-9436-617d1982fbcb.png)
   ps:This is a screenshot of redis key naming for limit count.
   
   part 1: common prefix
   part 2: consumer username
   part 3:  ?
   
   Is this part(part 3) a version attribute? Can you help find out where the key generation rules are in the source code?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Firstsawyou commented on issue #4124: request help: how to get current limit count from redis cache?

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #4124:
URL: https://github.com/apache/apisix/issues/4124#issuecomment-826278553


   > 1. If I use redis to store limit count cache, how to get the current value of count by admin? Is there an admin api interface to get this or do I need to get it from redis by myself?
   
   The limit count cache value cannot be obtained through admin api, can you refer to the method here to obtain it.
   
   https://github.com/apache/apisix/blob/681b0bda1625c2d9030489e0c5ef42f688c65156/apisix/plugins/limit-count/limit-count-redis-cluster.lua#L85-L101
   
   https://github.com/apache/apisix/blob/681b0bda1625c2d9030489e0c5ef42f688c65156/apisix/plugins/limit-count.lua#L169
   
   >2.How is the key value naming rule of limit count defined?
   
   This cannot be customized, it is generated according to certain rules.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org