1

我试图在 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 射线设置单独的任务,但仍然无法正常工作。有什么我想念的吗?

4

1 回答 1

0

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

于 2020-03-11T17:24:03.967 回答