|
| 1 | +{ |
| 2 | + "$schema": "http://json-schema.org/draft-07/schema#", |
| 3 | + "$id": "https://www.krakend.io/schema/v2.10/governance/processors.json", |
| 4 | + "title": "Governance processors.", |
| 5 | + "description": "Declares rules and limits to be enforced.", |
| 6 | + "type": "object", |
| 7 | + "required": [ |
| 8 | + "quotas" |
| 9 | + ], |
| 10 | + "properties": { |
| 11 | + "quotas": { |
| 12 | + "description": "The list of quota processors available for attachment. You can have multiple processors with different configurations.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 13 | + "type": "array", |
| 14 | + "items": { |
| 15 | + "type": "object", |
| 16 | + "required": [ |
| 17 | + "name", |
| 18 | + "connection_name", |
| 19 | + "rules" |
| 20 | + ], |
| 21 | + "properties": { |
| 22 | + "connection_name": { |
| 23 | + "description": "The name of the [Redis connection](https://www.krakend.io/docs/enterprise/service-settings/redis-connection-pools/) to use, it must exist under the `redis` namespace at the service level and written exactly as declared.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 24 | + "type": "string" |
| 25 | + }, |
| 26 | + "deny_queue_flush_interval": { |
| 27 | + "description": "When you have a `rejecter_cache`, the time interval to write the events stored in the buffer in the bloom filter. This is the maximum time that can elapse before the events are written to the bloom filter.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 28 | + "default": "1s", |
| 29 | + "$ref": "../timeunits.json#/$defs/timeunit", |
| 30 | + "type": "string" |
| 31 | + }, |
| 32 | + "deny_queue_flush_threshold": { |
| 33 | + "description": "When you have a `rejecter_cache`, the maximum number of events in the buffer that will force a write to the bloom filter event when the flush interval has not kicked in yet.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 34 | + "default": 10, |
| 35 | + "type": "integer" |
| 36 | + }, |
| 37 | + "deny_queue_size": { |
| 38 | + "description": "When you have a `rejecter_cache`, the size of the buffer (number of events stored) to write in the bloomfilter. It defaults to the number of cores on the machine. This is the maximum number of events that can be stored in memory before being written to the bloom filter. You should not set this value unless you are seeing increased latencies on very high-concurrency scenarios; ask support for help.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 39 | + "type": "integer" |
| 40 | + }, |
| 41 | + "hash_keys": { |
| 42 | + "description": "Whether to hash the keys used for quota consumption. If you have PII (Personal Identifiable Information) in the keys (like an email), enable this option to `true` to avoid Redis containing clear text keys with PII. This is a setting for privacy, enabling it may affect performance because of the extra hashing, and makes data exploration difficult.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 43 | + "default": false, |
| 44 | + "type": "boolean" |
| 45 | + }, |
| 46 | + "name": { |
| 47 | + "description": "Name of the quota. The exact name you type here is the one you need to reference when you attach a quota under the `governance/quota` namespace, and is also part of the key name on the persistence layer.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 48 | + "examples": [ |
| 49 | + "public_api", |
| 50 | + "LLM" |
| 51 | + ], |
| 52 | + "type": "string" |
| 53 | + }, |
| 54 | + "on_failure_allow": { |
| 55 | + "description": "What to do with the user request if Redis is down. When `true`, allows continuing to perform requests even when Redis is unreachable, but the quota won't be counted. When `false`, the request is rejected and the user receives a 500 error. This is a fail-safe option, but it may lead to quota overconsumption.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 56 | + "type": "boolean" |
| 57 | + }, |
| 58 | + "on_failure_backoff_strategy": { |
| 59 | + "description": "The backoff strategy to use when Redis is unreachable. The default is `exponential`, which means that the time between retries will increase exponentially. The other option is `linear`, which means that the time between retries will be constant.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 60 | + "default": "exponential", |
| 61 | + "enum": [ |
| 62 | + "linear", |
| 63 | + "exponential" |
| 64 | + ] |
| 65 | + }, |
| 66 | + "on_failure_max_retries": { |
| 67 | + "description": "Maximum number of retries to Redis when it is unreachable. Once the retries are exhausted, the processor is no longer usable and the quota stops working until the Redis connection is restored and the service restarted. The users will be able to consume content depending on the `on_failure_allow` option. A zero value means no retries.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 68 | + "default": 0, |
| 69 | + "type": "integer" |
| 70 | + }, |
| 71 | + "rejecter_cache": { |
| 72 | + "description": "The bloom filter configuration that you use to cache rejections. The bloom filter is used to store the events that are rejected by the quota processor. This is useful to avoid rejecting the same event multiple times.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 73 | + "type": "object", |
| 74 | + "required": [ |
| 75 | + "N", |
| 76 | + "P" |
| 77 | + ], |
| 78 | + "properties": { |
| 79 | + "N": { |
| 80 | + "title": "Number of elements", |
| 81 | + "description": "The maximum `N`umber of elements you want to keep in the bloom filter. Tens of millions work fine on machines with low resources.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 82 | + "examples": [ |
| 83 | + 10000000 |
| 84 | + ], |
| 85 | + "type": "integer" |
| 86 | + }, |
| 87 | + "P": { |
| 88 | + "title": "Probability", |
| 89 | + "description": "The `P`robability of returning a false positive. E.g.,`1e-7` for one false positive every 10 million different tokens. The values `N` and `P` determine the size of the resulting bloom filter to fulfill your expectations. E.g: 0.0000001\n\nSee: https://www.krakend.io/docs/authorization/revoking-tokens/\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 90 | + "examples": [ |
| 91 | + 1e-07, |
| 92 | + 1e-07 |
| 93 | + ], |
| 94 | + "type": "number" |
| 95 | + }, |
| 96 | + "cleanup_interval": { |
| 97 | + "description": "The time interval to clean up the bloom filter. This is the maximum time that can elapse before the bloom filter is cleaned up.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 98 | + "default": "30m", |
| 99 | + "$ref": "../timeunits.json#/$defs/timeunit", |
| 100 | + "type": "string" |
| 101 | + }, |
| 102 | + "hash_name": { |
| 103 | + "title": "Hash function name", |
| 104 | + "description": "Either `optimal` (recommended) or `default`. The `optimal` consumes less CPU but has less entropy when generating the hash, although the loss is negligible.\n\nSee: https://www.krakend.io/docs/authorization/revoking-tokens/\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 105 | + "default": "optimal", |
| 106 | + "enum": [ |
| 107 | + "optimal", |
| 108 | + "default" |
| 109 | + ] |
| 110 | + } |
| 111 | + }, |
| 112 | + "patternProperties": { |
| 113 | + "^[@$_#]": {} |
| 114 | + }, |
| 115 | + "additionalProperties": false |
| 116 | + }, |
| 117 | + "rules": { |
| 118 | + "description": "The rules to use for the quota processor.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 119 | + "type": "array", |
| 120 | + "items": { |
| 121 | + "type": "object", |
| 122 | + "required": [ |
| 123 | + "name", |
| 124 | + "limits" |
| 125 | + ], |
| 126 | + "properties": { |
| 127 | + "limits": { |
| 128 | + "description": "The limits for the rule. The limits are defined as an array of objects, each object containing an amount and a unit.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 129 | + "examples": [ |
| 130 | + [ |
| 131 | + { |
| 132 | + "amount": 10, |
| 133 | + "unit": "hour" |
| 134 | + }, |
| 135 | + { |
| 136 | + "amount": 250, |
| 137 | + "unit": "day" |
| 138 | + } |
| 139 | + ] |
| 140 | + ], |
| 141 | + "type": "array", |
| 142 | + "items": { |
| 143 | + "type": "object", |
| 144 | + "required": [ |
| 145 | + "amount", |
| 146 | + "unit" |
| 147 | + ], |
| 148 | + "properties": { |
| 149 | + "amount": { |
| 150 | + "description": "The amount of the limit. This is the maximum number of requests that can be made in the given time unit.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 151 | + "type": "number" |
| 152 | + }, |
| 153 | + "unit": { |
| 154 | + "description": "The time unit for the limit.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 155 | + "enum": [ |
| 156 | + "second", |
| 157 | + "minute", |
| 158 | + "hour", |
| 159 | + "day", |
| 160 | + "week", |
| 161 | + "month", |
| 162 | + "year" |
| 163 | + ] |
| 164 | + } |
| 165 | + }, |
| 166 | + "patternProperties": { |
| 167 | + "^[@$_#]": {} |
| 168 | + }, |
| 169 | + "additionalProperties": false |
| 170 | + } |
| 171 | + }, |
| 172 | + "name": { |
| 173 | + "description": "The name of the rule. This is the name that will be used to identify the rule in the logs and metrics. It is also the plan name.\n\nSee: https://www.krakend.io/docs/enterprise/governance/quota/", |
| 174 | + "examples": [ |
| 175 | + "gold", |
| 176 | + "silver" |
| 177 | + ], |
| 178 | + "type": "string" |
| 179 | + } |
| 180 | + }, |
| 181 | + "patternProperties": { |
| 182 | + "^[@$_#]": {} |
| 183 | + }, |
| 184 | + "additionalProperties": false |
| 185 | + } |
| 186 | + } |
| 187 | + }, |
| 188 | + "patternProperties": { |
| 189 | + "^[@$_#]": {} |
| 190 | + }, |
| 191 | + "additionalProperties": false |
| 192 | + } |
| 193 | + } |
| 194 | + }, |
| 195 | + "patternProperties": { |
| 196 | + "^[@$_#]": {} |
| 197 | + }, |
| 198 | + "additionalProperties": false |
| 199 | +} |
0 commit comments