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 中,我有像
这样的默认日志/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.dtaillogs.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天全站免登陆