【问题标题】:logstash configuration to execute a command to elastic searchlogstash 配置执行弹性搜索命令
【发布时间】:2017-11-19 09:20:41
【问题描述】:

我正在通过主机 ubuntu 16.04 在 3 个 docker 容器中运行 ELK 堆栈 问题是在配置 logstash.conf 文件以执行“ifconfig”或“netstat -ano”之类的命令后出现错误。我的 logstash.conf 文件是:

input {
  exec {
  
    command => "netsat -ano"
    codec => "json"
    interval => 5
  }
}
output{
  elasticsearch { hosts => ["elasticsearch:9200"]}
}
 i get this error after entering this command ( docker run -h logstash --name logstash --link elasticsearch:elasticsearch -it --rm -v "$PWD":/config-dir logstash -f /config-dir/logstash1.conf)
14:29:30.703 [[main]<exec] ERROR logstash.inputs.exec - Error while running command {:command=>"netsat -ano", :e=>#<IOError: Cannot run program "netsat" (in directory "/"): error=2, No such file or directory>, :backtrace=>["org/jruby/RubyIO.java:4380:in `popen'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-exec-3.1.2/lib/logstash/inputs/exec.rb:76:in `execute'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-exec-3.1.2/lib/logstash/inputs/exec.rb:75:in `execute'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-exec-3.1.2/lib/logstash/inputs/exec.rb:40:in `inner_run'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/logstash-input-exec-3.1.2/lib/logstash/inputs/exec.rb:34:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:443:in `inputworker'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:436:in `start_input'"]}

谁能帮忙,请提前谢谢!

【问题讨论】:

  • 你把netstat 打错了netsat
  • 实际上是 netstat 我知道这是一个错误我也尝试了“ifconfig”下面标记的相同错误

标签: elasticsearch docker logstash exec


【解决方案1】:

您需要为这些命令提供完整路径,因为运行 Logstash 的命令不包含这些目录。

input {
  exec {
    command => "/bin/netsat -ano"
    codec => "json"
    interval => 5
  }

}

【讨论】:

  • 实际上它是“/sbin/netstat -ano”,但它也不起作用,下面标记的同样错误
猜你喜欢
  • 2018-11-25
  • 1970-01-01
  • 1970-01-01
  • 2014-03-26
  • 1970-01-01
  • 1970-01-01
  • 2022-12-04
  • 2015-03-16
  • 2017-08-30
相关资源
最近更新 更多