我有大约30个docker容器,它们使用标签'container_name'将日志写入journald。我正在使用google-fluentd将日志发送到Google Stackdriver。我发现很难使用journald中给出的标记对日志进行分类。
在google-fluentd.conf中,我尝试将日志逐个标记到Stackdriver,如下所示。
<source>
@type systemd
filters [{ "_SYSTEMD_UNIT": "test.service" }]
<storage>
@type local
persistent true
path /var/run/google-fluentd/test.service.pos
</storage>
read_from_head true
tag test.service
</source>
这有效,但如果服务数量增加,我将不得不一次包含一个块。如果不这样做,是否有一种简单的方法可以从标记中获取容器日志并写入Stackdriver?
不推荐使用filters
参数。请改用matches
参数。
使用@include
指令重用配置块: