Docker GELF driver env option

2019-07-11 06:55发布

Having an issue getting the --log-opt env=env1,env2 option to work with docker 1.12 swarm-mode and graylog. All of my logs are being sent fine and the tag is coming through. However I see nothing coming in at all from the env setting. I also tried using --log-opt labels=dev but had the same issue.

They are being shipped to graylog and I'm not seeing it anywhere within any of the log fields that come through. Any ideas on what I'm doing wrong here?

docker service create --log-driver=gelf --log-opt gelf-address=udp://logserver:12201 --log-opt tag="app-name" --log-opt env=dev ...

1条回答
Anthone
2楼-- · 2019-07-11 07:30

I had the same issue and answered it here: https://stackoverflow.com/a/40182515/701260

When you use --log-opt env=dev, it will retrieve the variable dev from environment and include it in the event eg. dev: <val-from-env.

Labels do the same with docker labels.

查看更多
登录 后发表回答