Skip to content

Instantly share code, notes, and snippets.

@nguyentienlong
Created September 30, 2018 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nguyentienlong/959ec860e2bb3255acd78613c8888eb8 to your computer and use it in GitHub Desktop.
Save nguyentienlong/959ec860e2bb3255acd78613c8888eb8 to your computer and use it in GitHub Desktop.
aws logs installation on ec2
#!/usr/bin/env bash
# install awscli
python2 -m pip install awscli
# create aws sym link if any issue
ln -s /usr/local/bin/aws /var/awslogs/bin/aws
# install awscli-cwlogs
python2 -m pip install awscli-cwlogs
# then run aws configure to setup aws credential
aws configure
# download cloud watch log agent
wget http://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py
# create conf file
touch awslogs-agent-config.conf
# sample content of awslogs-agent-config.conf file
: << 'END_COMMENT'
[general]
state_file = /var/awslogs/state/agent-state
[/var/log/syslog]
file = /var/log/nginx/access.log
log_group_name = $your_host_name_nginx_server
log_stream_name = $your_host_name_nginx_access_logs
datetime_format = %b %d %H:%M:%S
END_COMMENT
# setup
python2 ./awslogs-agent-setup.py --region ap-southeast-1 -n -c awslogs-agent-config.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment