Is there a way to track which ECS task a request is forwarded to by a NLB?

0

According to the docs, NLB uses a flow hash algorithm:

For TCP traffic, the load balancer selects a target using a flow hash algorithm based on the protocol, source IP address, source port, destination IP address, destination port, and TCP sequence number. The TCP connections from a client have different source ports and sequence numbers, and can be routed to different targets. Each individual TCP connection is routed to a single target for the life of the connection.

https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html

I'm trying to track what this looks like with our live traffic but I'm not seeing any metrics in CW that might tell me.

Is it possible to view metrics that could tell this story?

已提问 4 个月前243 查看次数
2 回答
1
已接受的回答

Hello.

I don't think you can see which task a request was assigned to using CloudWatch metrics.
https://docs.aws.amazon.com/AmazonECS/latest/userguide/monitoring-fargate-usage.html

Therefore, I think it is best to check the access logs and application logs of ECS Fargate tasks.
https://docs.aws.amazon.com/AmazonECS/latest/userguide/using_awslogs.html

profile picture
专家
已回答 4 个月前
1

Hi,

I believe that NLB request tracing adding a header X-Amzn-Trace-Id and forwarding is what you need: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-request-tracing.html

If you correlate this header with the CW logs at NLB, you can define which task gets which requets.

If your final goal is to track unhealthy targets, this blog post may help: https://aws.amazon.com/blogs/networking-and-content-delivery/identifying-unhealthy-targets-of-elastic-load-balancer/

Best,

Didier

profile pictureAWS
专家
已回答 4 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则