rule

Summary

Rules dictate logic on traffic is routed. Attributes from incoming requests are matched against preconfigured rule objects to determine where the outgoing upstream request should be routed. Rules are specified programmatically in routes and shared_rules as an array in the Rules attribute.

Example object

1
{
2
"rule_key": "rkey1",
3
"methods": [
4
"GET"
5
],
6
"matches": [
7
{
8
"kind": "header",
9
"from": {
10
"key": "routeTo",
11
"value": "passthrough-cluster"
12
}
13
}
14
],
15
"constraints": {
16
"light": [
17
{
18
"cluster_key": "passthrough-cluster",
19
"weight": 1
20
}
21
]
22
}
23
}
Copied!

Fields

rule_key

A unique key for each rule. When a request is routed by a rule, it appends the header "X-Gm-Rule" with the rule key.

methods

The supported request methods for this rule. Setting to an empty array will allow all methods.

matches

Matches for this rule.

constraints

The constraints field defines cluster_constraint arrays that map requests to clusters. These fall into two categories: light and dark.
light
The light field determines the "live" or "primary" traffic to/from the clusters. Responses from these requests are returned to the caller.
Currently, the constraints field must set a light field that contains an array of cluster_constraints.
1
"constraints" : {
2
"light": [
3
{
4
"cluster_key": "example-service-1.0",
5
"weight": 10
6
},
7
{
8
"cluster_key": "example-service-1.1",
9
"weight": 1
10
}
11
]
12
}
Copied!
dark
The dark field determines the "shadow" traffic to send to a cluster. The responses from this traffic will never be returned to the caller. This traffic can be used to do test deployments of new clusters, or to tap traffic for monitoring/audit purposes without worrying about the affect on the user.
The below example would shadow 50% of the traffic from the 1.0 cluster to the 2.0 cluster. Note that weight is interpreted as a percentage from 0-100 when used in the dark constraint.
1
"constraints" : {
2
"light": [
3
{
4
"cluster_key": "example-service-1.0",
5
"weight": 1
6
}
7
],
8
"dark": [
9
{
10
"cluster_key": "example-service-2.0",
11
"weight": 50
12
}
13
]
14
}
Copied!

cohort_seed

This field has no effect.
Last modified 7mo ago
Export as PDF
Copy link