【发布时间】:2017-09-27 02:10:01
【问题描述】:
我有一个在 Docker 引擎上运行的 Fluentd 和 Elasticsearch 设置。我有大量服务要登录到 Fluentd。
我想做的是为我运行的每个服务创建一个标签,并将该标签用作 Elasticsearch 中的索引。这是我的设置:
<source>
@type forward
port 24224
bind 0.0.0.0
</source>
<match docker.service1>
@type elasticsearch
host "172.20.0.3"
port 9200
index_name service1
type_name fluentd
flush_interval 10s
</match>
<match docker.service2>
@type elasticsearch
host "172.20.0.3"
port 9200
index_name service2
type_name fluentd
flush_interval 10s
</match>
等等。
必须为我创建的每个服务都包含一个新的匹配标签会很烦人,因为我希望能够在不更新我的 fluentd 配置的情况下添加新服务。有没有办法做这样的事情:
<source>
@type forward
port 24224
bind 0.0.0.0
</source>
<match docker.**>
@type elasticsearch
host "172.20.0.3"
port 9200
index_name $(TAG)
type_name fluentd
flush_interval 10s
</match>
我在哪里使用 $(TAG) 变量来表明我希望 Tag 名称成为索引的名称?
我已经从我找到的答案 here: ${tag_parts[0]} 中尝试过这个。这实际上是作为我的索引打印的。所以我的索引是“${tag_parts[0]}”。
提前致谢。
【问题讨论】:
标签: elasticsearch docker fluentd