Change the app-name sent by docker's syslog driver
Asked Answered
A

1

11

I'm using Papertrail to collect my Docker container's logs. Do to that, I used the syslog driver when I created the container:

sudo docker run --name my_container --log-driver=syslog  ...

... and added the following line to my /etc/rsyslog.conf

*.* @logsXXX.papertrailapp.com:YYYY

At the end, I get on Papertrail logs like this:

Apr 24 13:41:55 ip-10-1-1-86 docker/3b00635360e6: 10.0.0.5 - - [24/Apr/2015:11:41:57 +0000] "GET /healthcheck HTTP/1.1" 200 0 "-" "" "-"

The problem is that the app-name (see syslog RFC) is docker/container_id

I would rather have the container name (or host). But I don't know how to do. I tried to set a specific hostname to my container like below, but it didn't work better:

sudo docker run --name my_container -h my_container --log-driver=syslog  ...
Arrogant answered 24/4, 2015 at 11:53 Comment(1)
Hopefully in docker v1.8 there will be a --log-opt option that could give you what you need. Source: blog.treasuredata.com/blog/2015/07/07/…Kilohertz
B
15

You can't do it. Here's a pending PR to add that feature: https://github.com/docker/docker/pull/12668

Hopefully it gets merged in soon. You could always roll your own, I suppose.

Update: Looks like this is slated for Docker 1.8

Update: This is now possible:

docker run --name my_container --log-driver=syslog --log-opt syslog-tag=my_application
Balch answered 26/4, 2015 at 20:23 Comment(1)
note: it's now "tag" and not "syslog-tag": docs.docker.com/engine/admin/logging/overview/#/syslog-optionsFant

© 2022 - 2024 — McMap. All rights reserved.