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


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.

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?

asked 3 months ago215 views
2 Answers
Accepted Answer


I don't think you can see which task a request was assigned to using CloudWatch metrics.

Therefore, I think it is best to check the access logs and application logs of ECS Fargate tasks.

profile picture
answered 3 months ago


I believe that NLB request tracing adding a header X-Amzn-Trace-Id and forwarding is what you need:

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:



profile pictureAWS
answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions