设置CloudWatch日志的明智方法(awslogs-agent) [英] A sane way to set up CloudWatch logs (awslogs-agent)

查看:484
本文介绍了设置CloudWatch日志的明智方法(awslogs-agent)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

tl; dr cloudwatch代理的配置为#$%^。有什么简单的方法吗?



我想在一个地方存储日志,所以我使用了Amazon CloudWatch Logs Agent。起初,我似乎只是添加了一个Resource,上面写着创建一个日志组,然后一个日志流并发送此文件,谢谢之类的东西-都是声明性和简洁的,但是...



根据此文档我必须设置JSON配置,该配置创建了一个BASH脚本,该脚本下载了一个Python脚本,该Python脚本设置了在另一种语言中使用生成的配置的服务。



我认为日志记录是经常使用的东西,因此必须有一种声明式的配置方式,而不是这种4语言的疯狂组合。我是否想念某些东西,还是操作世界如此痛苦?



感谢您的想法!

解决方案

您已将doco特定于CloudFormation链接了,因此一堆复杂性可能与该上下文有关。



以下是该文档的独立文档Cloudwatch Logs Agent:





如果您使用的是Amazon Linux,则可以通过yum安装'awslogs'系统软件包。完成后,通过确保在CLI的配置文件中具有以下部分,可以为AWS CLI启用日志插件:

  [plugins] 
cwlogs = cwlogs

例如,系统软件包应创建一个文件在/etc/awslogs/awscli.conf下。您可以通过设置...

  AWS_CONFIG_FILE = / etc / awslogs / awscli.conf 

...环境变量。



一旦完成,您可以:

  $ aws日志推送帮助

  $ cat / path / to / some / file | aws日志推送[选项] 

该代理还附带了帮助程序,可以使各种日志文件保持同步。 / p>

tl;dr The configuration of cloudwatch agent is #$%^. Any straightforward way?

I wanted one place to store the logs, so I used Amazon CloudWatch Logs Agent. At first it seemed like I'd just add a Resource saying something like "create a log group, then a log stream and send this file, thank you" - all declarative and neat, but...

According to this doc I had to setup JSON configuration that created a BASH script that downloaded a Python script that set up the service that used a generated config in yet-another-language somewhere else.

I'd think logging is something frequently used, so there must be a declarative configuration way, not this 4-language crazy combo. Am I missing something, or is ops world so painful?

Thanks for ideas!

解决方案

You've linked doco particular to CloudFormation so a bunch of the complexity is probably associated with that context.

Here's the stand-alone documentation for the Cloudwatch Logs Agent:

If you're on Amazon Linux, you can install the 'awslogs' system package via yum. Once that's done, you can enable the logs plugin for the AWS CLI by making sure you have the following section in the CLI's config file:

[plugins]
cwlogs = cwlogs

E.g., the system package should create a file under /etc/awslogs/awscli.conf . You can use that file by setting the...

AWS_CONFIG_FILE=/etc/awslogs/awscli.conf

...environment variable.

Once that's all done, you can:

$ aws logs push help

and

$ cat /path/to/some/file | aws logs push [options]

The agent also comes with helpers to keep various log files in sync.

这篇关于设置CloudWatch日志的明智方法(awslogs-agent)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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