在Lambda指标中注册负载均衡器错误 [英] Registering Load Balancer Errors In Lambda Metrics

查看:76
本文介绍了在Lambda指标中注册负载均衡器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个在AWS中运行的解决方案,该解决方案使用以下工作流程.

I currently have a solution running in AWS that uses the following workflow.

SQS =>Lambda =>ApplicationLoadBalancer =>目标群体=>法尔盖特

SQS => Lambda => ApplicationLoadBalancer => Target group => Fargate

此解决方案效果很好,但是在负载均衡器中注册的错误(因此来自Fargate的服务)没有反映在Lambda函数中.

This solution works great, but errors that are registered in the load balancer, hence coming from the service in Fargate, are not reflected in the Lambda function.

由于Lambda请求已注册为 200 ,因此该消息将从队列中删除,这时应将其真正添加回队列或发送到我的死信队列中.

Since the Lambda request is registered as a 200, the message is removed from the queue, when it should really be added back to the queue, or sent to my dead letter queue.

为明确起见,当发生错误时,我可以在我的负载均衡器指标中看到它,而不是在我的lambda函数中看到.

任何帮助将不胜感激,谢谢!

Any help would be much appreciated, thanks!

推荐答案

为阐明SQS的功能,如果lambda以成功状态退出(执行过程中没有错误),则会删除该消息.现在回到问题所在,我想您的代码需要确保来自LoadBalancer的响应状态正确.

To clarify the funcionality of SQS, the message gets removed if the lambda exited with success status (no errors inside of execution). Now back to the problem i guess on your code you need to ensure the response status from your LoadBalancer is correct.

我将使用的方法是,如果Lambda从LoadBalancer获得错误(状态码!= 200),则引发异常以导致Lambda执行失败.发生这种情况时,邮件将被重试几次(这些时间是您在邮件进入死信队列之前配置的发送时间),并且在重试被取消后,邮件将从原始队列中删除并发送到死信.

The aproach i'll use is if the Lambda gets a error from the LoadBalancer (statuscode != 200) throw a exception to cause fail execution of lambda. When this happens the message will be retried some times (these times of deliveries you configure before message goes to dead-letter queue) and when retries are exahusted the message gets removed from original queue and send to dead-letter.

这篇关于在Lambda指标中注册负载均衡器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆