代码之家  ›  专栏  ›  技术社区  ›  Héctor

Filebeat没有在Elasticsearch中创建索引

  •  0
  • Héctor  · 技术社区  · 7 年前

    我正在设置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的Docker容器中运行。

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

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

    2 回复  |  直到 7 年前
        1
  •  1
  •   Héctor    7 年前

    解决了的!我没有在主机和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
    
        2
  •  0
  •   Govardhan Reddy    7 年前

    您可以如下创建索引

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