cat 命令的 Windows 等价物使用 Logstash 将数据提取到 ElasticSearch

标签 windows elasticsearch command-line logstash

我正在尝试运行 ELK for NGINX Plus (JSON) example在 Windows 10 机器上,我挂断了寻找与以下 unix 命令等效的 Windows 命令以将日志数据提取到 Elasticsearch 中:

cat nginxplus_json_logs | <path_to_logstash_root_dir>/bin/logstash -f nginxplus_json_logstash.conf

来自 this questionthis question我知道 type 可以执行一些与 unix 中的 cat 相同的操作。我尝试了用 type 替换 cat 的完全相同的命令,这不出所料地不起作用。这是我的命令和回应:

type nginxplus_json_logs.txt | ../logstash-2.1.1/bin/logstash -f nginxplus_json_logstash.conf

'..' is not recognized as an internal or external command,
operable program or batch file.

是否可以使用 type 命令复制该操作?如果是这样,我需要如何更改格式化命令的方式?

最佳答案

在 Windows 上,您的命令应该使用反斜杠“\”而不是正斜杠“/”,并且您需要调用 logstash.bat 文件而不是 logstash

所以你的命令必须看起来像这样(确保首先 cd 进入正确的文件夹):

type nginxplus_json_logs.txt | ..\logstash-2.1.1\bin\logstash.bat -f nginxplus_json_logstash.conf

此外,您拥有的 logstash 配置文件适用于 Logstash 1.5.4,因为您拥有 2.1.1,您可以将 elasticsearch 输出修改为如下所示:

  elasticsearch {
    hosts => ["localhost:9200"]
    index => "nginxplus_json_elk_example"
    document_type => "logs"
    template => "./nginxplus_json_template.json"
    template_name => "nginxplus_json_elk_example"
    template_overwrite => true
  }

关于cat 命令的 Windows 等价物使用 Logstash 将数据提取到 ElasticSearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35370346/

相关文章:

windows - 在 VB6 中使用自定义 MouseIcon

sql-server - 从SQL Server加载数据以进行 Elasticsearch

command-line - 具有/pp(/preprocess)的MSbuild 4不会写入经过预处理的文件

windows - 如何通过程序检查应用是否发出某种声音?

c# - 使用 C# 为 Windows 设置 ipv6

c++ - Qt 4.7.3 中缺少 Qtcreator.exe

javascript - Elasticsearch 滚动限制结果数

ruby-on-rails - 如何使用 bool 值限制Elasticsearch查询结果?

php - 如何从命令行执行类中的方法

windows - 我如何在批处理文件中获得 dirname() 的等价物?