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?

gefragt vor 4 Monaten243 Aufrufe
2 Antworten
1
Akzeptierte Antwort

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
EXPERTE
beantwortet vor 4 Monaten
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
EXPERTE
beantwortet vor 4 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen