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
asked 6 months ago334 views
1 Answer
0
Accepted Answer

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
EXPERT
answered 6 months ago
profile pictureAWS
EXPERT
reviewed 6 months ago
  • Okay, I'll try it, thank you

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions