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

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南