[英]If you are using AWS to autoscale spot instances of your application, how do you handle logging?
Looking into adding autoscaling of a portion of our application using AWS simple message queuing which would launch EC2 on-demand or spot instances based on queue backlog.考虑使用 AWS 简单消息队列为我们的应用程序的一部分添加自动缩放功能,该消息队列将按需启动 EC2 或基于队列积压的现场实例。
One question I had, is how do you deal with collecting logs from autoscaled instances?我有一个问题,您如何处理从自动缩放实例收集日志? New instances are spun up based on an image, but then they are shut down when complete.
新实例基于图像启动,但完成后它们会关闭。 Currently, if there is an issue with one of our services, which causes it to crash, we have a system to automatically restart the service, but the logs and core dump files are there to review.
目前,如果我们的一项服务出现问题,导致它崩溃,我们有一个系统可以自动重新启动服务,但日志和核心转储文件需要查看。 If we switch to an autoscaling system, where new instance are spun up, how do you get logs and core dump files when there is a failure?
如果我们切换到自动扩展系统,新实例会在其中启动,那么当出现故障时如何获取日志和核心转储文件? Particularly if the instance is spun down.
特别是如果实例被降速。
Good practice is to ship these logs and aggregate them somewhere else, and there are many services such as DataDog and Rapid7 which will do this for you at a cost.好的做法是将这些日志发送到其他地方并将它们聚合到其他地方,并且有许多服务,例如 DataDog 和 Rapid7,它们会为你做这件事,但需要付出一定的代价。
AWS however provides CloudWatch logs, which gives you a central place to store and view logs.然而,AWS 提供了 CloudWatch 日志,它为您提供了一个存储和查看日志的中心位置。 It also allows you then to give users access to logs on the AWS console without them having to ssh onto a server.
它还允许您随后允许用户访问 AWS 控制台上的日志,而无需将 ssh 安装到服务器上。
Shipping your logs to CloudWatch logs requires the installation of the CloudWatch agent on your server and specifying in the config which logs to ship.将您的日志传送到 CloudWatch 日志需要在您的服务器上安装 CloudWatch 代理并在配置中指定要传送的日志。
You could install the CloudWatch agent once and create an AMI of that server to use in your autoscaling group, or install and configure the CloudWatch agent in userdata for every time a server is spun up.您可以安装一次 CloudWatch 代理并创建该服务器的 AMI 以在您的自动扩展组中使用,或者在每次启动服务器时在 userdata 中安装和配置 CloudWatch 代理。
All the information you need to get started can be found here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html您可以在此处找到入门所需的所有信息: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.