简体   繁体   English

适用于Elasticbeanstalk的AWS CloudWatch日志

[英]aws cloudwatch log for elasticbeanstalk

From webapp, end-user will specify start time and end time for fetching logs (either in .zip format or to just display log in new tab). 最终用户将从webapp中指定获取日志的开始时间和结束时间(采用.zip格式或仅在新选项卡中显示日志)。 I want to use cloudwatch for logging of elasticbeanstalk. 我想使用cloudwatch记录Elasticbeanstalk。 What are the available JAVA api's for doing this. 有哪些可用的JAVA api可以做到这一点。 like enabling cloudwatch log in elasticbeanstalk and creating log stream etc 例如在elasticbeanstalk中启用cloudwatch日志并创建日志流等

Why do you want use java api? 为什么要使用Java API? You can follow the below step to install & configure cloud-watch log in EB ENV. 您可以按照以下步骤在EB ENV中安装和配置云监视日志。

  1. You should add cloud-watch policy with your elastic beanstalk ec2 role. 您应该使用弹性beantalk ec2角色添加云监视策略。
  2. Write config in .ebextension to install & configure the cloud-watch logs on EB based servers. 在.ebextension中编写配置,以在基于EB的服务器上安装和配置云监视日志。

Example config for cloud-watch log installation & configuration: 云监视日志安装和配置的示例配置:

packages:
  yum:
    awslogs: []

container_commands:
  01_get_awslogs_conf_file:
    command: "cp .ebextensions/awslogs.conf /etc/awslogs/awslogs.conf"
  03_restart_awslogs:
    command: "sudo service awslogs restart"
  04_start_awslogs_at_system_boot:
    command: "sudo chkconfig awslogs on"
  1. Your awslogs.conf should be available in .ebextensions directory. 您的awslogs.conf应该在.ebextensions目录中可用。

Example file of awslogs.conf awslogs.conf的示例文件

[general]
state_file = value
logging_config_file = value
use_gzip_http_content_encoding = [true | false]

[logstream1]
log_group_name = value
log_stream_name = value
datetime_format = value
time_zone = [LOCAL|UTC]
file = value
file_fingerprint_lines = integer | integer-integer
multi_line_start_pattern = regex | {datetime_format}
initial_position = [start_of_file | end_of_file]
encoding = [ascii|utf_8|..]
buffer_duration = integer
batch_count = integer
batch_size = integer

If you are not getting log under cloud-watch log on AWS console then check the agent log on your server. 如果您没有在AWS控制台上的cloud-watch日志下获取日志,请检查服务器上的代理日志。 Agent default log path will be /var/log/awslogs.log 代理程序的默认日志路径为/var/log/awslogs.log

Hope, This will help you to setup cloud watch log on EB. 希望,这将帮助您在EB上设置云监视日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM