Consumer Groups Reference

Use consumer groups to manage custom rate limiting configuration for subsets of consumers.

The consumer_groups endpoint works together with the Rate Limiting Advanced plugin. To use consumer groups for rate limiting, configure the plugin with the enforce_consumer_groups and consumer_groups parameters, then use the /consumer_groups endpoint to manage the groups.

For more information and examples of setting up and managing consumer groups, see the Consumer Groups examples.

Note: Consumer groups are not supported in declarative configuration with decK. If you have consumer groups in your configuration, decK will ignore them.

List consumer groups

List all consumer groups

Endpoint

/consumer_groups

Response

  1. HTTP/1.1 200 OK
  1. {
  2. "data": [
  3. {
  4. "created_at": 1557522650,
  5. "id": "42b022c1-eb3c-4512-badc-1aee8c0f50b5",
  6. "name": "my_group"
  7. },
  8. {
  9. "created_at": 1637706162,
  10. "id": "fa6881b2-f49f-4007-9475-577cd21d34f4",
  11. "name": "my_group2"
  12. }
  13. ],
  14. "next": null
  15. }

List a specific consumer group

Endpoint

/consumer_groups/{GROUP_NAME|GROUP_ID}

AttributeDescription
GROUP_NAME|GROUP_ID
required
The name or UUID of the consumer group.

Response

  1. HTTP/1.1 200 OK
  1. {
  2. "consumer_group": {
  3. "created_at": 1638917780,
  4. "id": "be4bcfca-b1df-4fac-83cc-5cf6774bf48e",
  5. "name": "JL"
  6. }
  7. }

List all consumers in a consumer group

Endpoint

/consumer_groups/{GROUP_NAME|GROUP_ID}/consumers

AttributeDescription
GROUP_NAME|GROUP_ID
required
The name or UUID of the consumer group.

Response

  1. HTTP/1.1 200 OK
  1. {
  2. "consumers": [
  3. {
  4. "created_at": 1638918560,
  5. "id": "288f2bfc-04e2-4ec3-b6f3-40408dff5417",
  6. "type": 0,
  7. "username": "BarryAllen",
  8. "username_lower": "barryallen"
  9. },
  10. {
  11. "created_at": 1638915577,
  12. "id": "8089a0e6-1d31-4e00-bf51-5b902899b4cb",
  13. "type": 0,
  14. "username": "DianaPrince",
  15. "username_lower": "dianaprince"
  16. }
  17. ]
  18. }

List consumer groups for a consumer

View all consumer groups that a consumer is assigned to.

Endpoint

/consumers/{CONSUMER_NAME|CONSUMER_ID}/consumer_groups

AttributeDescription
USERNAME|CONSUMER_ID
required
The name or UUID of the consumer.

Response

  1. HTTP/1.1 200 OK
  1. {
  2. "consumer_groups": [
  3. {
  4. "created_at": 1638918476,
  5. "id": "e2c3f16e-22c7-4ef4-b6e4-ab25c522b339",
  6. "name": "JL"
  7. }
  8. ]
  9. }

Create a consumer group

Endpoint

/consumer_groups

Request body

AttributeDescription
name
required
A unique name for the consumer group you want to create.

Response

  1. HTTP 201 Created
  1. {
  2. "created_at": 1557522650,
  3. "id": "fa6881b2-f49f-4007-9475-577cd21d34f4",
  4. "name": "JL",
  5. }

Endpoint

/consumer_groups/{GROUP_NAME}

AttributeDescription
GROUP_NAME
required
A unique name for the consumer group you want to create.

Response

  1. HTTP 201 Created
  1. {
  2. "created_at": 1557522650,
  3. "id": "fa6881b2-f49f-4007-9475-577cd21d34f4",
  4. "name": "JL",
  5. }

Add a consumer to a group

Add a consumer to a specific consumer group.

If you add a consumer to multiple groups:

  • If all groups are allowed by the Rate Limiting Advanced plugin, only the first group’s settings will apply.
  • Otherwise, whichever group is specified in the Rate Limiting Advanced plugin will be active.

Consumers endpoint

/consumers/{CONSUMER_NAME|CONSUMER_ID}/consumer_groups

AttributeDescription
CONSUMER_NAME|CONSUMER_ID
required
The name or UUID of the consumer.

Request body

AttributeDescription
group
required
The name or ID of the group to add the consumer to.

Response

  1. HTTP 201 Created
  1. {
  2. "consumer": {
  3. "created_at": 1638918560,
  4. "custom_id": null,
  5. "id": "288f2bfc-04e2-4ec3-b6f3-40408dff5417",
  6. "tags": null,
  7. "type": 0,
  8. "username": "BarryAllen",
  9. "username_lower": "barryallen"
  10. },
  11. "consumer_groups": [
  12. {
  13. "created_at": 1638918476,
  14. "id": "e2c3f16e-22c7-4ef4-b6e4-ab25c522b339",
  15. "name": "JL"
  16. }
  17. ]
  18. }

Consumer groups endpoint

/consumer_groups/{GROUP_NAME|GROUP_ID}/consumers

AttributeDescription
GROUP_NAME|GROUP_ID
required
The name or UUID of the consumer group.

Request body

AttributeDescription
consumer
required
The name or ID of the consumer to add to this group.

Response

  1. HTTP 201 Created
  1. {
  2. "consumer_group": {
  3. "created_at": 1638915521,
  4. "id": "8a4bba3c-7f82-45f0-8121-ed4d2847c4a4",
  5. "name": "JL"
  6. },
  7. "consumers": [
  8. {
  9. "created_at": 1638915577,
  10. "id": "8089a0e6-1d31-4e00-bf51-5b902899b4cb",
  11. "type": 0,
  12. "username": "DianaPrince",
  13. "username_lower": "dianaprince"
  14. }
  15. ]
  16. }

Delete a consumer group

Deleting a consumer group removes all consumers from that group. It does not delete any consumers.

Endpoint

/consumer_groups/{GROUP_NAME|GROUP_ID}

AttributeDescription
GROUP_NAME|GROUP_ID
required
The name or UUID of the consumer group to delete.

Response

  1. HTTP/1.1 204 No Content

Remove consumers

Remove a consumer from all groups

Endpoint

/consumers/{CONSUMER_NAME|CONSUMER_ID}/consumer_groups

AttributeDescription
CONSUMER_NAME|CONSUMER_ID
required
The name or UUID of the consumer to remove from all groups.

Response

  1. HTTP/1.1 204 No Content

Remove a consumer from a consumer group

Consumer endpoint

/consumers/{CONSUMER_NAME|CONSUMER_ID}/consumer_groups/{GROUP_NAME|GROUP_ID}

AttributeDescription
CONSUMER_NAME|CONSUMER_ID
required
The name or UUID of the consumer to remove.
GROUP_NAME|GROUP_ID
required
The name or UUID of the consumer group to remove the consumer from.

Response

  1. HTTP/1.1 204 No Content

Consumer groups endpoint

/consumer_groups/{GROUP_NAME|GROUP_ID}/consumers/{CONSUMER_NAME|CONSUMER_ID}

AttributeDescription
GROUP_NAME|GROUP_ID
required
The name or UUID of the consumer group to remove the consumer from.
CONSUMER_NAME|CONSUMER_ID
required
The name or UUID of the consumer to remove.

Response

  1. HTTP/1.1 204 No Content

Remove all consumers from a consumer group

/consumer_groups/{GROUP_NAME|GROUP_ID}/consumers

AttributeDescription
GROUP_NAME|GROUP_ID
required
The name or UUID of the consumer group to remove all consumers from.

Response

  1. HTTP/1.1 204 No Content

Configure rate limiting for a consumer group

Define custom rate limiting settings for a consumer group. This endpoint overrides the settings of the Rate Limiting Advanced plugin.

/consumer_groups/{GROUP_NAME|GROUP_ID}/overrides/plugins/rate-limiting-advanced

AttributeDescription
GROUP_NAME|GROUP_ID
required
The name or UUID of the consumer group to configure.

Request Body

AttributeDescription
limit
required
An array of one or more requests-per-window limits to apply. There must be a matching number of window limits and sizes specified.
window_size
required
An array of one or more window sizes to apply a limit to (defined in seconds). There must be a matching number of window limits and sizes specified.
window_type
optional
Set the time window type to either sliding (default) or fixed.
retry_after_jitter_max
optional
The upper bound of a jitter (random delay) in seconds to be added to the Retry-After header of denied requests (status = 429) in order to prevent all the clients from coming back at the same time. The lower bound of the jitter is 0; in this case, the Retry-After header is equal to the RateLimit-Reset header.

Response

  1. HTTP/1.1 201 Created
  1. {
  2. "config": {
  3. "limit": [
  4. 10
  5. ],
  6. "retry_after_jitter_max": 0,
  7. "window_size": [
  8. 10
  9. ],
  10. "window_type": "sliding"
  11. },
  12. "group": "test-group",
  13. "plugin": "rate-limiting-advanced"
  14. }