Windows 相当于 cat 命令使用 Logstash 将数据提取到 ElasticSearch
Windows equivalent for cat command to ingest data into ElasticSearch using Logstash
我正在尝试在 Windows 10 机器上 运行 ELK for NGINX Plus (JSON) example,但在寻找等同于以下 unix 命令的 Windows 时挂断了将日志数据提取到 Elasticsearch:
cat nginxplus_json_logs | <path_to_logstash_root_dir>/bin/logstash -f nginxplus_json_logstash.conf
来自 this question and 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
}
我正在尝试在 Windows 10 机器上 运行 ELK for NGINX Plus (JSON) example,但在寻找等同于以下 unix 命令的 Windows 时挂断了将日志数据提取到 Elasticsearch:
cat nginxplus_json_logs | <path_to_logstash_root_dir>/bin/logstash -f nginxplus_json_logstash.conf
来自 this question and 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
}