How to non-interactively install and configure the CloudWatch Logs agent on an EC2 Ubuntu instance using a shell script?

1

I used the "-n" parameter in the command line and shell script to install the awslos agent non-interactively, but the error "ERROR: Missing required arguments. Please run with --help for details."

sudo python2 awslogs-agent-setup.py -n --region us-gov-west-1

Please tell me how to complete the non-interactive installation process in a shell script, otherwise the software cannot be installed automatically.

DD-Boom
已提问 6 个月前348 查看次数
1 回答
0
已接受的回答

Hello.

If you use the "-n" option, you must specify the configuration file using the "-c" option.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/EC2NewInstanceCWL.html

#!/bin/bash
curl https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O
chmod +x ./awslogs-agent-setup.py
./awslogs-agent-setup.py -n -r us-east-1 -c s3://DOC-EXAMPLE-BUCKET1/my-config-file

Additionally, since the CloudWatch Logs agent is being deprecated, we recommend using the CloudWatch Agent to configure log output settings.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/download-cloudwatch-agent-commandline.html#download-CloudWatch-Agent-on-EC2-Instance-commandline-first

profile picture
专家
已回答 6 个月前
profile pictureAWS
专家
已审核 6 个月前
  • Okay, I'll try it, thank you

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则