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

main.tf#L7
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

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

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

template.json#L1919
    "AWS::XRay::SamplingRule": {
      "Type": "AWS::XRay::SamplingRule",
      "Properties": {}
    },
    "AWS::IoT::ProvisioningTemplate": {
      "Type": "AWS::IoT::ProvisioningTemplate",

Parameters

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 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.

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.