This is the new AWS CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the AWS CloudFormation User Guide.
AWS::XRay::SamplingRule
Use the AWS::XRay::SamplingRule resource to specify a sampling rule, which controls sampling behavior for instrumented applications.
Include a SamplingRule entity to create or update a sampling rule.
Note
SamplingRule.Version can only be set when creating a sampling rule. Updating the version
will cause the update to fail.
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" : { "SamplingRule" :SamplingRule, "Tags" :[ Tag, ... ]} }
YAML
Type: AWS::XRay::SamplingRule Properties: SamplingRule:SamplingRuleTags:- Tag
Properties
SamplingRule-
The sampling rule to be created or updated.
Required: No
Type: SamplingRule
Update requires: No interruption
-
An array of key-value pairs to apply to this resource.
Required: No
Type: Array of Tag
Update requires: No interruption
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the Amazon Resource Name (ARN) of the sampling rule.
For more information about using the Ref function, see Ref.
Fn::GetAtt
The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.
RuleARN-
The sampling rule ARN that was created or updated.
Examples
Create sampling rule
This example creates a new sampling rule called MySamplingRule.
JSON
{ "AWSTemplateFormatVersion": "2010-09-09T00:00:00.000Z", "Resources": { "MySamplingRuleResource": { "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: MySamplingRuleResource: 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": { "MySamplingRuleResource": { "Type": "AWS::XRay::SamplingRule", "Properties": { "SamplingRule": { "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: MySamplingRuleResource: Type: AWS::XRay::SamplingRule Properties: SamplingRule: 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