Forked from nguyentienlong/aws_logs_installation_on_ec2.sh
Created
June 14, 2019 19:11
-
-
Save Hadryan/7315915b13ebecc5b48416ef94a382b6 to your computer and use it in GitHub Desktop.
aws logs installation on ec2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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