AWS::XRay::SamplingRule
Use the AWS::XRay::SamplingRule
resource to specify a sampling rule, which controls sampling behavior for instrumented applications.
A new sampling rule is created by specifying a SamplingRule
. To change the configuration of an existing sampling rule, specify a SamplingRuleUpdate
.
Services retrieve rules with GetSamplingRules, and evaluate each rule in ascending order of priority for each request. If a rule matches, the service records a trace, borrowing it from the reservoir size. After 10 seconds, the service reports back to X-Ray with GetSamplingTargets to get updated versions of each in-use rule. The updated rule contains a trace quota that the service can use instead of borrowing from the reservoir.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::XRay::SamplingRule", "Properties" : { "RuleName" :
String
, "SamplingRule" :SamplingRule
, "SamplingRuleRecord" :SamplingRuleRecord
, "SamplingRuleUpdate" :SamplingRuleUpdate
, "Tags" :[ Json, ... ]
} }
YAML
Type: AWS::XRay::SamplingRule Properties: RuleName:
String
SamplingRule:SamplingRule
SamplingRuleRecord:SamplingRuleRecord
SamplingRuleUpdate:SamplingRuleUpdate
Tags:- Json
Properties
RuleName
-
The name of the sampling rule. Specify a rule by either name or ARN, but not both. Used only when deleting a sampling rule. When creating or updating a sampling rule, use the
RuleName
orRuleARN
properties withinSamplingRule
orSamplingRuleUpdate
.Required: No
Type: String
Minimum:
1
Maximum:
32
Update requires: No interruption
SamplingRule
-
The sampling rule to be created.
Must be provided if creating a new sampling rule. Not valid when updating an existing sampling rule.
Required: Conditional
Type: SamplingRule
Update requires: No interruption
SamplingRuleRecord
Not currently supported by AWS CloudFormation.
Required: No
Type: SamplingRuleRecord
Update requires: No interruption
SamplingRuleUpdate
-
A document specifying changes to a sampling rule's configuration.
Must be provided if updating an existing sampling rule. Not valid when creating a new sampling rule.
Note The
Version
of a sampling rule cannot be updated, and is not part ofSamplingRuleUpdate
.Required: Conditional
Type: SamplingRuleUpdate
Update requires: No interruption
Tags
-
An array of key-value pairs to apply to this resource.
For more information, see Tag.
Required: No
Type: List of Json
Update requires: No interruption
Return values
Fn::GetAtt
Examples
Create sampling rule
This example creates a new sampling rule called MySamplingRule.
JSON
{ "AWSTemplateFormatVersion": "2010-09-09T00:00:00.000Z", "Resources": { "SamplingRule": { "Type": "AWS::XRay::SamplingRule", "Properties": { "SamplingRule": { "RuleName": "MySamplingRule", "ResourceARN": "*", "Priority": 2, "FixedRate": 0.05, "ReservoirSize": 50, "ServiceName": "MyServiceName", "ServiceType": "MyServiceType", "Host": "MyHost", "HTTPMethod": "GET", "URLPath": "*", "Version": 1 } } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Resources: SamplingRule: Type: AWS::XRay::SamplingRule Properties: SamplingRule: RuleName: MySamplingRule ResourceARN: "*" Priority: 2 FixedRate: 0.05 ReservoirSize: 50 ServiceName: "MyServiceName" ServiceType: "MyServiceType" Host: "MyHost" HTTPMethod: "GET" URLPath: "*" Version: 1
Update sampling rule
This example updates an existing sampling rule called MySamplingRule.
JSON
{ "AWSTemplateFormatVersion": "2010-09-09T00:00:00.000Z", "Resources": { "SamplingRule": { "Type": "AWS::XRay::SamplingRule", "Properties": { "SamplingRuleUpdate": { "RuleName": "MySamplingRule", "ResourceARN": "*", "Priority": 1, "FixedRate": 0.07, "ReservoirSize": 20, "ServiceName": "MyServiceName", "ServiceType": "MyServiceType", "Host": "MyHost", "HTTPMethod": "GET", "URLPath": "*" } } } } }
YAML
AWSTemplateFormatVersion: 2010-09-09 Resources: SamplingRule: Type: AWS::XRay::SamplingRule Properties: SamplingRuleUpdate: RuleName: MySamplingRule ResourceARN: "*" Priority: 1 FixedRate: 0.07 ReservoirSize: 20 ServiceName: "MyServiceName" ServiceType: "MyServiceType" Host: "MyHost" HTTPMethod: "GET" URLPath: "*"
See also
-
CreateSamplingRule action in the X-Ray API Reference