【问题标题】:Unable to read input logs filebeat无法读取输入日志 filebeat
【发布时间】:2021-11-11 08:28:22
【问题描述】:

我对 docker 很陌生,我正在尝试使用 Filebeat 设置 ELK。我在机器 1 中有一个用于 filebeat 设置的容器,我正在尝试将来自 /mnt/logs/temp.log 的日志(它们是非容器日志)收集到机器 2 中的 ELK 容器中。这是我的 filebeat 配置:-

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

filebeat.autodiscover:
  providers:
    - type: docker
      hints.enabled: true
      hints.default_config:
        type: container
        paths:
          - /mnt/logs/temp.log

processors:
- add_cloud_metadata: ~

output.elasticsearch:
  hosts: '${ELASTICSEARCH_HOSTS:42.23.12.131:9042}'

即使我将 filebeat.yml 配置更改为以下内容,它似乎也不会向 ES 发送任何日志:-

filebeat.inputs:
- type: log
  paths:
    - /mnt/logs/temp.log

output.elasticsearch:
  hosts: ["42.23.12.131:9042"]

有人可以帮助我或将我指向任何与此相关的网站文章或文档吗? filebeat 和 ELK 容器的版本是 7.14.0。

编辑:ELK 的 docker-compose 文件是:-

version: '2.2'

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.14.0
    volumes:
      - type: bind
        source: ./elasticsearch/elasticsearch.yml
        target: /usr/share/elasticsearch/config/elasticsearch.yml
        read_only: true
      - type: volume
        source: elasticsearch
        target: /usr/share/elasticsearch/data
    environment:
      ES_JAVA_OPTS: "-Xmx512m -Xms512m"
      discovery.type: single-node
    ports:
      - "9200:9200"
      - "9300:9300"
    networks:
      - elk

  logstash:
    image: docker.elastic.co/logstash/logstash:7.14.0
    volumes:
      - type: bind
        source: ./logstash/config/logstash.yml
        target: /usr/share/logstash/config/logstash.yml
        read_only: true
      - type: bind
        source: ./logstash/pipeline.conf
        target: /usr/share/logstash/pipeline.conf
        read_only: true
    ports:
      - "5044:5044/udp"
      - "9600:9600"
    environment:
      LS_JAVA_OPTS: "-Xmx512m -Xms512m"
    networks:
      - elk
    depends_on:
      - elasticsearch

  kibana:
    image: docker.elastic.co/kibana/kibana:7.14.0
    volumes:
      - type: bind
        source: ./kibana/kibana.yml
        target: /usr/share/kibana/config/kibana.yml
        read_only: true
    ports:
      - "5601:5601"
    networks:
      - elk
    depends_on:
      - elasticsearch

networks:
  elk:
    driver: bridge

volumes:
  elasticsearch:

【问题讨论】:

  • 主机1和主机2用docker-compose配置文件还是其他方式?
  • @YLR host2 即 elk 堆栈是使用 docker-compose 设置的,而 host1 即 filebeat 容器是通过以下文章设置的:- elastic.co/guide/en/beats/filebeat/current/…
  • 好的,您能否就您的问题发送我们的 docker-compose 文件,看起来 host1 (FB 1) 在 docker-compose 堆栈之外看不到弹性
  • @YLR 已添加到主帖中。

标签: docker elasticsearch centos7 filebeat


【解决方案1】:

在您的 docker-compose 文件中,仅此端口暴露在容器外部(考虑到端口 9042 是您在 elasticsearch 端配置的端口):

ports:
  - "9200:9200"
  - "9300:9300"

所以,如果你添加目标端口9042,它必须工作。所以这一定是这样的:

ports:
  - "9200:9200"
  - "9300:9300"
  - "9042:9042"

如果不是您在 elasticsearhc 中配置的端口 9042,这意味着您必须从 filebeat 代理更改配置以获得正确的端口(可能是 9200 em>)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-07
    • 1970-01-01
    相关资源
    最近更新 更多