AWS X-Ray Sampling Rule
This page shows how to write Terraform and CloudFormation for X-Ray Sampling Rule and write them securely.
aws_xray_sampling_rule (Terraform)
The Sampling Rule in X-Ray can be configured in Terraform with the resource name aws_xray_sampling_rule
. The following sections describe 1 example of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_xray_sampling_rule" "this" {
attributes = var.attributes
fixed_rate = var.fixed_rate
host = var.host
http_method = var.http_method
priority = var.priority
Parameters
-
arn
optional computed - string -
attributes
optional - map from string to string -
fixed_rate
required - number -
host
required - string -
http_method
required - string -
id
optional computed - string -
priority
required - number -
reservoir_size
required - number -
resource_arn
required - string -
rule_name
optional - string -
service_name
required - string -
service_type
required - string -
tags
optional - map from string to string -
url_path
required - string -
version
required - number
Explanation in Terraform Registry
Creates and manages an AWS XRay Sampling Rule.
AWS::XRay::SamplingRule (CloudFormation)
The SamplingRule in XRay can be configured in CloudFormation with the resource name AWS::XRay::SamplingRule
. The following sections describe 1 example of how to use the resource and its parameters.
Example Usage from GitHub
"AWS::XRay::SamplingRule": {
"Type": "AWS::XRay::SamplingRule",
"Properties": {}
},
"AWS::IoT::ProvisioningTemplate": {
"Type": "AWS::IoT::ProvisioningTemplate",
Parameters
-
SamplingRule
optional - SamplingRule -
SamplingRuleRecord
optional - SamplingRuleRecord -
SamplingRuleUpdate
optional - SamplingRuleUpdate -
RuleName
optional - String -
Tags
optional - List
Explanation in CloudFormation Registry
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 aSamplingRule
. To change the configuration of an existing sampling rule, specify aSamplingRuleUpdate
. 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.
Frequently asked questions
What is AWS X-Ray Sampling Rule?
AWS X-Ray Sampling Rule is a resource for X-Ray of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS X-Ray Sampling Rule?
For Terraform, the niveklabs/aws source code example is useful. See the Terraform Example section for further details.
For CloudFormation, the mhlabs/aws-icons-directory source code example is useful. See the CloudFormation Example section for further details.