如何从docker发送param到流利地动态决定文件输出

时间:2016-03-28 14:54:21

标签: docker fluentd

我希望我的hello-world容器输出到fluentD - 我希望FluentD将其动态设置为文件夹

想法就是像这样启动容器

docker run --log-driver=fluentd --log-opt fluentdLogsDirName=docker.{{.NAME}} hello-world

和流利的配置文件是这样的

<source>
  @type forward
</source>

<match docker.**>
  @type file
  path /var/log/fluentd/#{fluentdLogsDirName}
  time_slice_format %Y%m%d
  time_slice_wait 10m
  time_format %Y%m%dT%H%M%S%z
  compress gzip
  utc
</match>

事情是 - fluentD在启动时出错(BTW流利也是码头工人)

2016-03-28 14:48:56 +0000 [info]: reading config file path="/fluentd/etc/test.conf"
2016-03-28 14:48:56 +0000 [info]: starting fluentd-0.12.21
2016-03-28 14:48:56 +0000 [info]: gem 'fluentd' version '0.12.21'
2016-03-28 14:48:56 +0000 [info]: adding match pattern="docker.**" type="stdout"
2016-03-28 14:48:56 +0000 [info]: adding match pattern="docker.**" type="file"
2016-03-28 14:48:56 +0000 [error]: config error file="/fluentd/etc/test.conf" error="out_file: `/var/log/fluentd/\#{fluentdLogsDirName}.20160328_0.log` is not writable"
2016-03-28 14:48:56 +0000 [info]: process finished code=256
2016-03-28 14:48:56 +0000 [warn]: process died within 1 second. exit.

启动了我的fluendd containter:

docker run -it -p 24224:24224 -v /blabla:/fluentd/etc -e FLUENTD_CONF=test.conf fluent/fluentd:latest

http://docs.fluentd.org/articles/out_file

1 个答案:

答案 0 :(得分:0)

我认为fluentdLogsDirName目前不是docker中流利的日志驱动程序的选项; https://docs.docker.com/engine/admin/logging/fluentd/

此外,Go模板({{ .Name }})仅支持标记https://docs.docker.com/engine/admin/logging/log_tags/),而不支持其他记录驱动程序的选项。

所以此刻,我认为这不可能