【问题标题】:Filebeat is not creating index in ElasticsearchFilebeat 未在 Elasticsearch 中创建索引
【发布时间】:2019-02-04 11:11:41
【问题描述】:

我正在设置 Filebeat 以将日志发送到 Elasticsearch。这是我的filebeat.yml:

filebeat.prospectors:
- type: log
  paths:
  - '/var/log/project/*.log'
  json.message_key: message

output.elasticsearch:
  hosts: ["localhost:9200"]

我有这个文件/var/log/project/test.log,里面有这个内容:

{ "message": "This is a test" }

我期待这个日志被发送到 Elasticsearch。 Elasticsearch 在 9200 的 localhost 的 Docker 容器中运行。

当我运行 filebeat (Docker) 时,Elasticsearch 中没有创建索引。所以,在 Kibana 中,我没有看到任何数据。

这是为什么呢? Filebeat不应该自动创建索引吗?

【问题讨论】:

    标签: elasticsearch kibana filebeat


    【解决方案1】:

    您可以如下创建索引

    output.elasticsearch:
    hosts: ["localhost:9200"]
    index: "test-%{+yyyy.MM.dd}"
    

    【讨论】:

    • 这会在 elasticsearch 中创建一个新索引还是连接到现有索引?
    【解决方案2】:

    解决了!我没有在主机和 Filebeat 容器之间共享日志目录,因此没有要发送的日志。

    我在运行 Filebeat 时添加了一个卷:

    docker run -it -v $(pwd)/filebeat.yml:/usr/share/filebeat/filebeat.yml -v /var/log/project/:/var/log/project/ docker.elastic.co/beats/filebeat:6.4.0
    

    【讨论】:

      猜你喜欢
      • 2023-01-03
      • 2021-04-25
      • 1970-01-01
      • 1970-01-01
      • 2015-05-27
      • 1970-01-01
      • 1970-01-01
      • 2017-05-25
      • 2022-01-18
      相关资源
      最近更新 更多