【问题标题】:AWS: CloudWatch agent configuration fileAWS:CloudWatch 代理配置文件
【发布时间】:2018-12-28 17:29:37
【问题描述】:
我正在尝试提供 CW 代理配置,关于后者应该跟踪哪些文件;
根据this documentation,此类信息应在/etc/awslogs/awslogs.conf 中配置(以及在/etc/awslogs/awscli.conf 中的适当区域设置)。
但是this page表示日志源(也可以?/应该?)在/tmp/cwlogs/*.conf中配置
第二个选项(/tmp 下)不会导致重启后 conf 文件丢失吗?
知道存储此类配置信息的正确位置是什么吗?
【问题讨论】:
标签:
amazon-web-services
amazon-cloudwatch
【解决方案1】:
最好在使用用户数据创建新实例时安装和配置 CloudWatch 日志代理。这样,每当您启动新实例时,您都会获取最新的代理版本和最新的配置文件。
将配置文件保存在 s3 中或作为 ssm 参数。
安装代理后,您可以通过传递“-a fetch-config”来启动它。
关于如何启动 CloudWatch 代理在以下链接中有详细描述。
链接cloudwatch log agent 查看“使用命令行在 Amazon EC2 实例上启动 CloudWatch 代理”
例如,如果 ami 是 linux(amazon 2) 并使用配置文件。下面应该做。
wget https://s3.amazonaws.com/amazoncloudwatch-agent/linux/amd64/latest/AmazonCloudWatchAgent.zip
unzip AmazonCloudWatchAgent.zip
./install.sh
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:path-to-config-file.json -s