准备规则文件
rule-apigateway-dev-10pct.json
json
{
"SamplingRule": {
"RuleName": "apigateway-prod-10pct",
"ResourceARN": "*",
"Priority": 100,
"FixedRate": 0.1,
"ReservoirSize": 0,
"ServiceName": "*",
"ServiceType": "*",
"Host": "*",
"HTTPMethod": "*",
"URLPath": "/prod/*",
"Version": 1,
"Attributes": {}
}
}
新增规则不会改变 Default,它仍然是 FixedRate=0.05、ReservoirSize=1。只有命中 /prod/* 的请求才会按 10% 采样。
添加采样规则
bash
aws xray create-sampling-rule --region cn-north-1 --cli-input-json file://rule-apigateway-dev-10pct.json
查看所有规则
bash
aws xray get-sampling-rules