我有一个奇怪的问题,我无法解决,因为我的问题,当寻找这个错误,是不同的。当尝试将Filebeat连接到Logstash时,人们似乎已经体验到了这一点。
但是,我试图直接将日志写入Elasticsearch,但我得到了与Logstash相关的错误,即使我甚至没有在Docker Compose中构建一个容器??
主码头组合文件:
version: '2.2'
services:
  filebeat:
    container_name: filebeat
    build:
      context: .
      dockerfile: filebeat.Dockerfile
    volumes:
      - ./logs:/var/log
    networks:
      - esnet
  elasticsearch:
    container_name: elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch:7.5.2
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      - discovery.type=single-node
      - cluster.name=docker-
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    networks:
      - esnet
  elastichq:
    container_name: elastichq
    image: elastichq/elasticsearch-hq
    ports:
      - 8080:5000
    environment:
      - HQ_DEFAULT_URL=http://elasticsearch:9200
      - HQ_ENABLE_SSL=False
      - HQ_DEBUG=FALSE
    networks:
      - esnet  
networks:
  esnet:DockerFile for Filebeat
FROM docker.elastic.co/beats/filebeat:7.5.2
COPY filebeat/filebeat.yml /usr/share/filebeat/filebeat.yml
USER root
RUN chown root:filebeat /usr/share/filebeat/filebeat.yml
RUN chmod 644 /usr/share/filebeat/filebeat.yml
USER filebeat我正在尝试读取已经采用Elasticsearch格式的Elasticsearch日志,因此在读取文档之后,我决定尝试直接将其写入Elasticsearch,根据应用程序的不同,这似乎是有效的。
我的Sample.json文件:
“{"@timestamp":"2020-02-10T09:35:20.7793960+00:00",”级别:“信息”、“messageTemplate”:“i的值为{LoopCountValue}”、“消息”:“i的值为0”、“字段”:{“LoopCountValue”:0、"SourceContext":"WebAppLogger.Startup“、”环境“:”开发“、"ApplicationName":"ELK Logging Demo”}
我的Filebeat.yml
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/*.json
  json.keys_under_root: true
  json.add_error_key: true
  json.message_key: log  
#----------------------------- Elasticsearch output --------------------------------
output.elasticsearch:
  hosts: ["elasticsearch:9200"]
  index: "sample-%{+YYYY.MM.dd}"正如这篇文章的标题所述,我在控制台中得到了以下消息:
文件节拍: 2020-02-10T09:38:24.438Z错误管道/输出. no :100未能连接回退(异步(tcp:// logstash :5044)):在127.0.0.11:53上查找日志存储:没有这样的主机
然后,当我最终尝试在ElasticHq中可视化数据时,不可避免的是,什么都没有。
到目前为止,我已经尝试使用像docker prune这样的命令,以防Docker发生了一些有趣的事情。
我遗漏了什么吗?
发布于 2020-02-10 10:12:59
您的filebeat.yml文件配置错误。看看这个错误:
Failed to connect to backoff(async(tcp://logstash:5044))Filebeat尝试连接到logstash,因为这是默认配置。事实上,一方面您显示了一个filebeat.yml文件,另一方面,您还没有在/usr/share/file节拍/filebeat.yml上挂载它-查看您的卷设置
  filebeat:
    container_name: filebeat
    build:
      context: .
      dockerfile: filebeat.Dockerfile
    volumes:
      - ./logs:/var/log
    networks:
      - esnet你应该把它装上去。如果您试图将其复制到带有dockerfile (为什么是?)的停靠容器中,那么是否有必要重新发明轮子并增加复杂性?--您应该使用根用户:
USER root并在docker-come.yml中将根用户添加到您的服务中:
user: roothttps://stackoverflow.com/questions/60147800
复制相似问题