API Gateway does not have X-Ray tracing enabled
Description
When an API Gateway stage has the active tracing feature enabled, Amazon API Gateway service automatically samples API invocation requests based on the sampling algorithm specified by AWS X-Ray.
With tracing enabled X-Ray can provide an end-to-end view of an entire HTTP request. You can use this to analyze latencies in APIs and their backend services.
Fix - Runtime
AWS Console
- Log in to the AWS Management Console at [https://console.aws.amazon.com/].
- Open the Amazon API Gateway console.
- In the APIs pane, choose the API, and then click Stages.
- In the Stages pane, choose the name of the stage.
- In the Stage Editor pane, choose the Logs/Tracing tab.
- To enable active X-Ray tracing, choose Enable X-Ray Tracing under X-Ray Tracing.
CLI Command
aws apigateway create-stage \
--rest-api-id {rest-api-id} \
--stage-name {stage-name} \
--deployment-id {deployment-id} \
--region {region} \
--tracing-enabled=true
Fix - Buildtime
Terraform
- Resource: aws_api_gateway_stage
- Argument: xray_tracing_enabled - (Optional) Whether active tracing with X-ray is enabled. Defaults to false.
resource "aws_api_gateway_stage" "test" {
...
stage_name = "prod"
+ xray_tracing_enabled = true
...
}
CloudFormation
- Resource: AWS::ApiGateway::Stage
- Argument: Properties.TracingEnabled
Resources:
MyStage:
Type: AWS::ApiGateway::Stage
Properties:
...
+ TracingEnabled: true
...