首页 > 解决方案 > filebeat 没有用我的名字创建索引

问题描述

我正在使用 filebeat 将我的应用程序日志发送到 Elasticsearch 并直接连接到我的 Elasticsearch 以发送日志。

我的文件节拍配置

filebeat.config:
  modules:
    path: ${path.config}/modules.d/*.yml
    reload.enabled: false

filebeat.inputs:
  - type: log
    paths:
      - "/var/log/*.log"
setup.ilm.enabled: false
setup.template.overwrite: true
output.elasticsearch:
  hosts: ["aws-es:443"]
  output.elasticsearch.index: "myapp-%{[agent.version]}-%{+yyyy.MM.dd}"
  username: '${ELASTICSEARCH_USERNAME:}'
  password: '${ELASTICSEARCH_PASSWORD:}

请注意,output.elasticsearch.index:我在 Elasticsearch 中将 myapp 作为我的索引名称的前缀,但 filebeat 正在使用filebeat-7.7.0-2020.05.31名称创建索引,即使用它自己的名称filebeat作为前缀,因为我有多个应用程序并希望创建一个单独的索引他们。

标签: elasticsearchfilebeat

解决方案


您需要 按照错误消息中的说明setup.template.name 进行设置。setup.template.pattern请在您的 filebeat.yml 中添加以下额外行。

setup.template:
  name: 'myapp'
  pattern: 'myapp-*'
  enabled: false

现在你的完整filebeat.yml 应该看起来像

filebeat.config: 模块: 路径: $ { path.config } /modules.d/ * .yml reload.enabled: false

  filebeat.inputs:
    -type: log
  paths:
    -"/var/log/*.log"
  setup.ilm.enabled: false
  setup.template.overwrite: true
  output.elasticsearch:
    hosts: ["aws-es:443"]
  output.elasticsearch.index: "myapp-%{[agent.version]}-%{+yyyy.MM.dd}"
  username: '${ELASTICSEARCH_USERNAME:}'
  password: '${ELASTICSEARCH_PASSWORD:}

  setup.template:
    name: 'myapp'
    pattern: 'myapp-*'
    enabled: false

推荐阅读