All Products
Search
Document Center

API Gateway:canary-header

Last Updated:Jun 17, 2026

The canary-header plug-in adds specified headers to requests based on a configured percentage and then re-matches routes. This enables percentage-based canary releases without requiring clients to carry a canary header.

Fields

Configuration item

Data type

Required

Default value

Description

weighted_headers

array of object

Yes

-

The headers to add to requests and their weights.

The following table describes the fields in weighted_headers.

Configuration item

Data type

Required

Default value

Description

added_key

string

Yes

-

The header key to add to requests.

added_value

string

Yes

-

The header value to add to requests.

weight

number

Yes

-

The weight of the header to add to requests. Unit: %. The total weight of all headers cannot exceed 100.

Note

If the total weight of all headers is less than 100, the remaining percentage of requests are forwarded without an added header.

Configuration examples

Global configuration

In this example, the x-higress-canary:gray header is added to 30% of requests, and the x-higress-canary:base header is added to 70% of requests.

weighted_headers: 
- added_key: x-higress-canary
  added_value: gray
  weight: 30
- added_key: x-higress-canary
  added_value: base
  weight: 70

In this example, the x-higress-canary:gray header is added to 30% of requests, and the remaining 70% are forwarded without an added header.

weighted_headers: 
- added_key: x-higress-canary
  added_value: gray
  weight: 30

Enable the plug-in for specific routes or domain names

When the route-a route is matched, the x-higress-canary:gray header is added to 30% of requests and the x-higress-canary:base header is added to 70% of requests. After the headers are added, routes are re-matched. For example, if a route named route-a-gray uses the x-higress-canary:gray header for matching, 30% of the route-a requests match the route-a-gray route, enabling percentage-based canary releases.

# Use the _rules_ field to configure fine-grained rules.
_rules_:
# Rule 1: Match a route name.
- _match_route_:
  - route-a
  weighted_headers: 
  - added_key: x-higress-canary
    added_value: gray
    weight: 30
  - added_key: x-higress-canary
    added_value: base
    weight: 70
# Rule 2: Match a domain name.
- _match_domain_:
  - "*.example.com"
  weighted_headers:
  - added_key: x-custom-header
    added_value: gray
    weight: 30
  - added_key: x-custom-header
    added_value: blue
    weight: 30
  - added_key: x-custom-header
    added_value: base
    weight: 40