我正在尝试运行 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 question和 this 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/