aws / amazon-ecs-agent

Amazon Elastic Container Service Agent
http://aws.amazon.com/ecs/
Apache License 2.0
2.08k stars 612 forks source link

unknown log opt 'tag' for gelf log driver #255

Closed pedros007 closed 8 years ago

pedros007 commented 8 years ago

The gelf Docker log driver includes an option --log-opt tag="database" which propagates into Gelf. I update my Task Definition to set "tag": "database", like so:

        "logConfiguration": {
            "logDriver": "gelf",
            "options": {
                "gelf-address": "udp://localhost:12201",
                "tag": "database"
            }
        },

However, when ECS attempts to start the task, it reports Failed to initialize logging driver: unknown log opt 'tag' for gelf log driver. Here's a snippet from /var/log/ecs/ecs-agent.log.2015-11-24-23:

2015-11-24T23:10:16Z [INFO] Sending container change module="eventhandler" event="ContainerChange: arn:aws:ecs:us-west-2:625865828265:task/2ee55313-756c-4849-9579-8b9cb864adc7 db -> STOPPED, Exit 128, , Reason CannotStartContainerError: API error (500): Cannot start container 4ec6cadbfb33d8850e6f87601a38080c65fb10d3ed3f938121a4246810b6dc11: Failed to initialize logging driver: unknown log opt 'tag' for gelf log driver , Known Sent: NONE" change="ContainerChange: arn:aws:ecs:us-west-2:625865828265:task/2ee55313-756c-4849-9579-8b9cb864adc7 db -> STOPPED, Exit 128, , Reason CannotStartContainerError: API error (500): Cannot start container 4ec6cadbfb33d8850e6f87601a38080c65fb10d3ed3f938121a4246810b6dc11: Failed to initialize logging driver: unknown log opt 'tag' for gelf log driver , Known Sent: NONE"

For the record, I am using the gelf driver to pipe logs to a Logstash container with an Elasticsearch output. (I start the logstash container during EC2 instance startup using cfn-init in my autoscaling group launch configuration). See my StackOverflow post for how gelf & logstash are configured. When --log-opt tag="database" is included in the docker run command, logstash propagates the tag into Elasticsearch. I think this is the same setup as proposed in #238.

I am running the 2015.09.b ECS optimized AMI in us-west-2 with an upgraded Docker

docker version
Client:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   f4bf5c7
 Built:        Mon Oct 12 18:01:15 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   f4bf5c7
 Built:        Mon Oct 12 18:01:15 UTC 2015
 OS/Arch:      linux/amd64

Here's my ECS config on the instance:

cat /etc/ecs/ecs.config
ECS_ENGINE_AUTH_TYPE=dockercfg
ECS_ENGINE_AUTH_DATA={"https://index.docker.io/v1/":{"auth":"xxxxxxxxxx","email":"foo@bar.com"}}
ECS_CLUSTER=pschmitt-ecs-cluster-ECSCluster-EFJ9O8TRBH4L
ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","syslog","gelf"]
samuelkarp commented 8 years ago

tag was added as part of Docker 1.9.0. Since you're using 1.8.3, you'll want to use gelf-tag (see https://github.com/docker/docker/commit/3be7146e14d1f5ced470c0c7e3066f091f468696#diff-23c22cbdd65ac434eaf6d52ee1b9e6b2L96).

samuelkarp commented 8 years ago

I'm going to close this for now, but please feel free to reopen if you continue to have issues using the gelf logging driver.