Aws X 射线不适用于 Fargate 上的边车容器

Aws x-ray doesn't work for a sidecar container on fargate

我尝试在 fargatge 上设置 aws x-ray。但是没有错误,指标也没有出现在 X 射线中。这是我的 fargate 任务定义的一部分。我尝试调试潜在的问题,但在使用 docker compose 和 x-ray 守护进程的本地机器上它起作用了,这表明应用程序配置正确。

demoRole - 具有对 xray 的完全访问权限

安全组 - 在 TCP 80,2000 和 UDP 2000 上对全世界开放

在那个特定的任务定义中,我添加了环境变量。但是删除它们没有任何改变。

{
  "executionRoleArn": "arn:aws:iam::************:role/demoRole",
  "containerDefinitions": [
    {
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "ecs/demo",
          "awslogs-region": "us-east-1",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        }
      ],
      "cpu": 224,
      "environment": [
        {
          "name": "AWS_XRAY_DAEMON_ADDRESS",
          "value": "0.0.0.0:2000"
        }
      ],
      "memory": 384,
      "image": "************.dkr.ecr.us-east-1.amazonaws.com/demo:06031131",
      "name": "demo"
    },
    {
      "logConfiguration": {
        "logDriver": "awslogs",
        "secretOptions": null,
        "options": {
          "awslogs-group": "ecs/demo",
          "awslogs-region": "us-east-1",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "portMappings": [
        {
          "hostPort": 2000,
          "protocol": "udp",
          "containerPort": 2000
        }
      ],
      "cpu": 32,
      "environment": [
        {
          "name": "AWS_REGION",
          "value": "us-east-1"
        }
      ],
      "memory": 128,
      "image": "amazon/aws-xray-daemon",
      "name": "xray-sidecar"
    }
  ],
  "requiresCompatibilities": [
    "FARGATE"
  ],
  "networkMode": "awsvpc",
  "cpu": "256",
  "status": "ACTIVE",
}

这些是来自两个容器的日志:

x 射线

2020-03-11 13:45:19caused by: Get http://169.254.169.254/latest/meta-data/instance-id: dial tcp 169.254.169.254:80: connect: invalid argument
2020-03-11 13:45:192020-03-11T12:45:19Z [Info] HTTP Proxy server using X-Ray Endpoint : https://xray.us-east-1.amazonaws.com
2020-03-11 13:45:192020-03-11T12:45:19Z [Info] Starting proxy http server on 0.0.0.0:2000
2020-03-11 13:45:182020-03-11T12:45:18Z [Info] Using region: us-east-1
2020-03-11 13:45:182020-03-11T12:45:18Z [Info] Initializing AWS X-Ray daemon 3.2.0
2020-03-11 13:45:182020-03-11T12:45:18Z [Info] Using buffer memory limit of 39 MB
2020-03-11 13:45:182020-03-11T12:45:18Z [Info] 624 segment buffers allocated

服务:

2020-03-11 14:18:42- - [11/Mar/2020:13:18:42 +0000] "GET /demo/health_check HTTP/1.0" 200 2 "-" "ELB-HealthChecker/2.0"
2020-03-11 14:18:42[2020-03-11 13:18:42 +0000] [27] [DEBUG] GET /demo/health_check
2020-03-11 14:18:42[2020-03-11 13:18:42 +0000] [25] [DEBUG] GET /demo/health_check
2020-03-11 14:18:35[2020-03-11 13:18:35,721] INFO in middleware: initializing xray middleware

在其他测试中,我尝试为 X 射线设置单独的任务,但仍然不起作用。有什么我想念的吗?

您能否在您正在检测的服务上启用 X-Ray SDK 的调试模式?看起来配置是正确的,这可能是您的仪器设置有问题。这将启用额外的日志,以便我们诊断问题。