我正在尝试提供 CW 代理配置,关于后者应该跟踪哪些文件;
根据 this documentation , 此类信息应在 /etc/awslogs/awslogs.conf
中配置(以及 /etc/awslogs/awscli.conf
中的适当区域设置)。
然而,this page表示日志源(也可以?/应该?)在 /tmp/cwlogs/*.conf
中配置
第二个选项(在 /tmp
下)不会导致重新启动后 conf 文件丢失吗?
知道存储此类配置信息的正确位置是什么吗?
最佳答案
最好在使用用户数据创建新实例时安装和配置 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
关于amazon-web-services - AWS : CloudWatch agent configuration file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53942268/