-
Notifications
You must be signed in to change notification settings - Fork 18.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable syslog logger to have access to env and labels #21724
enable syslog logger to have access to env and labels #21724
Conversation
why not |
@flyinprogrammer could you make sure to update the documentation as well to mention the new options? https://github.com/docker/docker/blob/master/docs/admin/logging/overview.md#syslog-options |
@thaJeztah is this good enough? |
LGTM but it needs a rebase |
@calavera done 😄 |
As an example of what is possible with the syslog logger: | ||
|
||
``` | ||
$ docker run -it --rm --log-driver syslog --log-opt tag="{{ (.ExtraAttributes nil).MESOS_TASK_ID }}" --log-opt env=MESOS_TASK_ID -e MESOS_TASK_ID=logtester.1234 flyinprogrammer/logtester |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I built the docs for this, and I think we should wrap this, otherwise only a small part of the example is visible;
Also, I suggest to change the label name to something that more clearly stands out as being for "illustrational" purposes (e.g. SOME_ENV_VAR
), so:
$ docker run -it --rm \
--log-driver syslog \
--log-opt tag="{{ (.ExtraAttributes nil).SOME_ENV_VAR }}" \
--log-opt env=SOME_ENV_VAR \
-e SOME_ENV_VAR=logtester.1234 \
flyinprogrammer/logtester
(I like the idea of the log tester image BTW!)
Signed-off-by: Alan Scherger <flyinprogrammer@gmail.com>
@thaJeztah thanks for the feedback! You should see your suggestions reflected in the latest push. As for logtester, it's been pretty helpful for testing log flows, and I should have a post coming out soon where I use it to performance test rsyslog. |
@flyinprogrammer yes, it looks simple and useful, nice 👍 |
LGTM |
LGTM 🐮 |
@flyinprogrammer Is there any way to append the labels/environment variables outside of the --log-opt tag parameter? I noticed that the syslog logging driver supports the use of --log-opt label but in testing couldn't get the labels to output. Running the following test: docker run returns: <30>Aug 18 21:19:35 foobar[2542]: hello world In this case I want the labels/environment variables to get included in the message section, as oppose to the header (the APP-NAME section). |
So this is still working as designed so far as I can tell:
generates:
You'll note that the magic of getting your variables into the
In order to do this you would need to provide your own syslog format as we've done here to provide support for rfc3164, rfc5424, and rfc5424micro. |
- What I did
I added
env
andlabels
as valid log options for the syslog logger.- How I did it
Well... there's only 1 commit, I reckon you can figure that out.
- How to verify it
You know I probably could write a test like this one: https://github.com/docker/docker/blob/master/daemon/logger/syslog/syslog_test.go#L40-L45
Or...
I could show you this:
Shell:
/var/log/syslog
:So this is pretty cool huh because it starts to address issues like this one:
mesosphere/marathon#717
So that's nifty huh 😸.
- A picture of a cute animal (not mandatory but encouraged)
Steve!
Signed-off-by: Alan Scherger flyinprogrammer@gmail.com