AWS Elastic Beanstalk:是否将自定义日志添加到CloudWatch? [英] AWS Elastic Beanstalk: Add custom logs to CloudWatch?

本文介绍了AWS Elastic Beanstalk:是否将自定义日志添加到CloudWatch?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将自定义日志添加到CloudWatch?已发送默认日志,但如何添加自定义日志?

How to add custom logs to CloudWatch? Defaults logs are sent but how to add a custom one?

我已经添加了如下文件:(在.ebextensions中)

I already added a file like this: (in .ebextensions)

files:
  "/opt/elasticbeanstalk/tasks/bundlelogs.d/applogs.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/app/current/logs/*

  "/opt/elasticbeanstalk/tasks/taillogs.d/cloud-init.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/app/current/logs/*

就像我做bundlelogs.d和taillogs.d这些自定义日志现在可以从控制台或Web拖尾或检索,这很好,但是它们不会持久存在,也不会在CloudWatch上发送。

As I did bundlelogs.d and taillogs.d these custom logs are now tailed or retrieved from the console or web, that's nice but they don't persist and are not sent on CloudWatch.

在CloudWatch I中具有默认的日志,例如

/aws/elasticbeanstalk/InstanceName/var/log/eb-activity.log

想要再有一个这样的人

/aws/elasticbeanstalk/InstanceName/var/app/current/logs/mycustomlog.log

In CloudWatch I have the defaults logs like
/aws/elasticbeanstalk/InstanceName/var/log/eb-activity.log
And I want to have another one like this
/aws/elasticbeanstalk/InstanceName/var/app/current/logs/mycustomlog.log

推荐答案

bundlelogs.d taillogs.d 都是从管理控制台检索的日志。您要做的是将默认日志(例如eb-activity.log)扩展到CloudWatch Logs。为了扩展日志流,您需要在 / etc / awslogs / config / 下添加另一个配置。配置应遵循代理配置文件格式

Both bundlelogs.d and taillogs.d are logs retrieved from management console. What you want to do is extend default logs (e.g. eb-activity.log) to CloudWatch Logs. In order to extend the log stream, you need to add another configuration under /etc/awslogs/config/. The configuration should follow the Agent Configuration file Format.

我已经成功地将日志扩展到了自定义的ubuntu / nginx / php平台。这是我的扩展文件仅供参考。这是一个官方样本仅供参考。

I've successfully extended my logs for my custom ubuntu/nginx/php platform. Here is my extension file FYI. Here is an official sample FYI.

在您的情况下,可能就像

In your case, it could be like

files:
  "/etc/awslogs/config/my_app_log.conf" :
    mode: "000600"
    owner: root
    group: root
    content: |
      [/var/app/current/logs/xxx.log]
      log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/app/current/logs/xxx.log"]]}`
      log_stream_name = {instance_id}
      file = /var/app/current/logs/xxx.log*

这篇关于AWS Elastic Beanstalk:是否将自定义日志添加到CloudWatch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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