Count Limit

Tracks numeric counts and enforces defined limits.

Use the Count Limit policy to track numerical counts and enforce limits such as login attempts, API usage, or per-client quotas.

Important: Configuring count limits with max at or close to 2^63 - 1 (the maximum value of a signed 64-bit integer) and very large weights such that limit counts can reach values near 2^63 - 1 is not recommended, as results may not be accurate when applying limits that could cause the count to exceed 2^63 - 1.

For more information on the policy parameter descriptions, see DataPower Nano Gateway documentation.

Example of a Count Limit policy in code view.

kind: CountLimit
apiVersion: api.ibm.com/v1
metadata:
  name: count-limit-sample
  version: 1.0
  namespace: sample
spec:
  limits: 
    - limitDef:
        name: "moderate-limit" #required -> the name to give to this rate limit. Make sure its unique!
        definition:
          $ref: sample:moderate-limit-def:1.0
        operation: "increment" # increment | decrement
  extensions:
    dp-nano-gateway:
      apiVersion: api.ibm.com/v1
      spec:
        limits: 
          - globalLimit: 
              name: "database-rate-limit" 
              operation: "increment" # increment | decrement
          - aliasLimit: 
              name: "basic-limit" 
              operation: "increment" # increment | decrement

---
kind: CountLimitDef 
apiVersion: api.ibm.com/v1
metadata:
  name: moderate-limit-def
  version: 1
  namespace: sample
spec:
  max: 50 #size of the RL bucket
  autoDecrement: true
  extensions: 
    dp-nano-gateway:
      apiVersion: api.ibm.com/v1
      spec:
        weightExpr: "$variable('workSize')" #optional - dynamic string
        dynamicValue: "$header('request', 'organisation-name')" #optional, can set a dynamic key to apply this rate limit to.