2

I'm using rate limiting plugin by Kong, I'm using the declarative mode with a config file like:

_format_version: "3.0"
_transform: true

services:
- name: service1
  url: https://example.com/api/endpoint1
  routes:
  - name: route1
    paths:
    - /path1
- name: service2
  url: https://example.com/api/endpoint2
  routes:
  - name: route2
    paths:
    - /path2

plugins:
- name: rate-limiting
  service: service1
  config:
    second: 5
    policy: local
    limit_by: service
- name: rate-limiting
  service: service2
  config:
    second: 5
    policy: local
    limit_by: service


for the rate limiting plugin I'm also using the attribute limit_by: service, because I want to rate limit all the requests arriving for that service not just by grouping by IP.

I have more or less 12 endpoints like the above conf. and for every endpoint I want to apply, up to now, the same rate limit, every time there is the need to add a block like that:

- name: rate-limiting
  service: serviceN
  config:
    second: 5
    policy: local
    limit_by: service

is it possible to specify a rate-limit for every service globally but still groupyng by the service name?

In the docs is written: enter image description here

so it seems that every time we need to add the limit_by property otherwise it should group requests by IP.

Is there any way to do it without repeating every tie the plugin block?

Thanks

1 Answers1

0

You can use the following to configure the plugin globally:

plugins:
- name: rate-limiting
  config:
    second: 5
    policy: local
    limit_by: service

The parameter limit_by configured to the value service defines the scope of the rate limit buckets by service id. There is no need to explicitly specify service names or ids.

samugi
  • 395
  • 5
  • 17