简体   繁体   English

如果您使用 AWS 自动扩展应用程序的 Spot 实例,您如何处理日志记录?

[英]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.

相关问题 当实例位于ELB后面时,如何设置AWS维护页面? - How do you put up a maintenance page for AWS when your instances are behind an ELB? 您如何区分EC2实例? - How do you distinguish your EC2 instances? 如何使用竞价型实例数据Feed将AWS EC2竞价型实例的使用情况和价格发送到S3存储桶 - How do I send aws ec2 spot instances usage and pricing to s3 bucket using spot instance data feed 如何将其他开发人员添加到您的AWS账户中 - How do you add additional developers to be part of your AWS account 您如何查看上传到 AWS 管理控制台的文件夹? - How do you view your folders uploaded to AWS Management Console? 您如何在 AWS 的组织中创建和查看实例? - How do you create and view instances in an Organization in AWS? 创建自动扩展组时如何将实例附加到AWS自动扩展? - How to attach instances to AWS autoscale when creating autoscale group? 您如何使用托管在 AWS 上的 grafana 监控您的响应时间 - how do you monitor your response times using grafana which are hosted on AWS 如何使用AWS CLI启用S3对象记录到Cloud Trail? - How do you enable S3 Object Logging to Cloud Trail using AWS CLI? 如何使用 AWS CLI 禁用 S3 对象日志记录到 Cloud Trail? - How do you disable S3 Object Logging to Cloud Trail using AWS CLI?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM