Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ RUN apt-get install -q -y python python-pip wget
RUN cd / ; wget https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py

ADD awslogs.conf.dummy /
RUN python /awslogs-agent-setup.py -n -r us-east-1 -c ./awslogs.conf.dummy
RUN mkdir /etc/cron.d
RUN python awslogs-agent-setup.py --region us-east-1 --non-interactive --configfile=./awslogs.conf.dummy
# ONBUILD ADD aws.conf /var/awslogs/etc/aws.conf
# ONBUILD ADD awslogs.conf /var/awslogs/etc/awslogs.conf

Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ log_group_name = nginx-server
* `AWS_LOGFORMAT` default is "%d/%b/%Y:%H:%M:%S %z"
* `AWS_DURATION` default is "5000"
* `AWS_GROUPNAME` default is "nginx-server"
* `AWS_STREAM_NAME` default is the instance_id
* `AWS_REGION` default is us-east-1 (region where logs are published)
* `AWS_INITIAL_POSITION` default is start-of-file (other option is end-of-file)

If you have not defined a role for this instance, then you will need to pass
the AWS keys
* `AWS_ACCESS_KEY_ID`
* `AWS_SECRET_ACCESS_KEY`


### Example

Expand All @@ -32,11 +41,16 @@ docker run -d --name nginx -v /mnt/logs:/var/log/nginx -p 80:80 sergeyzh/centos6
docker run -d --name awslogs -e AWS_LOGFILE=/mnt/logs/access.log -e AWS_DURATION=10000 -v /mnt/logs:/mnt/logs sergeyzh/awslogs
```

Now you can see access logs of your Nginx at [AWS Console](https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logs:).
Now you can see access logs of your Nginx at [AWS Console](https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#logs:).

NOTE: Of course you should run it on the Amazon EC2 and you should set IAM role for you instance according [manual](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/QuickStartEC2Instance.html).

If you do not then run as follows

docker run -d --name awslogs -e AWS_LOGFILE=/var/log/applogs.log -e AWS_DURATION=5000 -e AWS_GROUPNAME=/ci/messaging -e AWS_LOGFORMAT="%Y-%m-%d %H:%M:%S" -v /var/lib/docker/log/myapp/:/var/log awslogs

### MAINTAINERS

* Ryuta Otaki <otaki.ryuta@classmethod.jp>
* Sergey Zhukov <sergey@jetbrains.com>
* David Rosenstark <drosenstark@gmail.com>
15 changes: 0 additions & 15 deletions eu-west-1/Dockerfile

This file was deleted.

128 changes: 0 additions & 128 deletions eu-west-1/awslogs.conf.dummy

This file was deleted.

41 changes: 0 additions & 41 deletions eu-west-1/run-services.sh

This file was deleted.

28 changes: 25 additions & 3 deletions run-services.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

shutdown_awslogs()
{
Expand All @@ -22,6 +22,9 @@ LOGFILE=${AWS_LOGFILE:-"/mnt/logs/access.log"}
LOGFORMAT=${AWS_LOGFORMAT:-"%d/%b/%Y:%H:%M:%S %z"}
DURATION=${AWS_DURATION:-"5000"}
GROUPNAME=${AWS_GROUPNAME:-"nginx-server"}
STREAM_NAME=${AWS_STREAM_NAME:-"{instance_id\}"}
INITIAL_POSITION=${AWS_INITIAL_POSITION:-"start-of-file"}
REGION=${AWS_REGION:-"us-east-1"}

cp -f /awslogs.conf.dummy /var/awslogs/etc/awslogs.conf

Expand All @@ -30,12 +33,31 @@ cat >> /var/awslogs/etc/awslogs.conf <<EOF
datetime_format = ${LOGFORMAT}
file = ${LOGFILE}
buffer_duration = ${DURATION}
log_stream_name = {instance_id}
initial_position = start_of_file
log_stream_name = ${STREAM_NAME}
initial_position = ${INITIAL_POSITION}
log_group_name = ${GROUPNAME}

EOF

cat > /var/awslogs/etc/aws.conf <<EOF
[plugins]
cwlogs = cwlogs
[default]
region = ${AWS_REGION}

EOF

if [ ! -z ${AWS_ACCESS_KEY_ID} ]; then

mkdir /root/.aws
cat > /root/.aws/credentials <<EOF
[default]
aws_access_key_id = ${AWS_ACCESS_KEY_ID}
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}
EOF

fi

/var/awslogs/bin/awslogs-agent-launcher.sh &

wait