带有 tcp 输入插件的 Logstash 不转发日志

问题描述 投票:0回答:1

我的本地计算机上运行着四个容器(Elastic search (8.10.2)、Logstash、Kibana 和我的应用程序容器),并且应用程序配置为将日志转发到 Logstash。我之前使用 UDP 在端口 9600 上转发日志,现在想更改为 TCP,但这样做遇到了一些问题。

这是我的

logstash.conf

input {
  tcp {
    port => 9600
  }
}
output {
  elasticsearch { 
    hosts => ["http://elasticsearch:9200"]
    index => "titan-%{+YYYY-MM-dd}"
    ilm_enabled => "true"
    ilm_rollover_alias => "myapp"
    ilm_pattern => "{now/d}-000001"
    ilm_policy => "myapp-policy"
    user => "elastic"
    password => <elastic-password>
  }
}

Logstash 服务:

  Logstash:
    image: logstash:8.10.2
    container_name: logstash
    restart: always
    volumes:
    - ./logstash/:/logstash_dir
    command: logstash -f /logstash_dir/logstash.conf 
    depends_on:
      - Elasticsearch
    ports:
    - '9600:9600'
    environment:
      LS_JAVA_OPTS: "-Xmx512m -Xms512m"

应用程序的 docker-compose:

logging:
      driver: syslog
      options:
        syslog-address: "tcp://localhost:9600"

通过上述配置,我可以看到索引,但无法获取任何数据。
另外,Logstash 容器会抛出以下错误

warning: thread "[main]<tcp" terminated with exception (report_on_exception is true):
ArgumentError: wrong number of arguments (given 2, expected 0..1)
    translate at /usr/share/logstash/vendor/bundle/jruby/3.1.0/gems/i18n-1.14.1/lib/i18n.rb:210
  inputworker at /usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:427
  start_input at /usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:405

我做错或遗漏了什么?

elasticsearch docker-compose logstash
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.