在winlogbeat中,使用自定义的索引不生效

使用 elasticseaarch 的winlogbeat ,想让事件存到自己定义的es索引中。设置了但是 不生效,最后还是存到默认的索引中了。

# ====================== Elasticsearch template settings =======================
setup.template.enable: false
setup.template.name: "windows"
setup.template.pattern: "windows-*"
setup.template.fields: "fields.yml"
setup.template.overwrite: false

# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch.index: "windows-%{+yyyy.MM.dd}"
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["172.16.5.200:9200"]

您需要将 output.elasticsearch.index 放在 output.elasticsearch 下面,而不是单独的一行,因为 output.elasticsearch 是一个字典,需要将所有 Elasticsearch 输出的设置放在其中。另外,您可以将 setup.template.enable 设置为 true,并将 setup.template.overwrite 设置为 true,以确保 Winlogbeat 使用您自己定义的模板。最终的配置可以调整成这样:

# ====================== Elasticsearch template settings =======================
setup.template.enable: true
setup.template.overwrite: true
setup.template.name: "windows"
setup.template.pattern: "windows-*"
setup.template.fields: "fields.yml"

# ---------------------------- Elasticsearch Output ----------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["172.16.5.200:9200"]
  index: "windows-%{+yyyy.MM.dd}"