驗證Logstash
[root@localhost logstash]# bin/logstash -e 'input { stdin { } } output { stdout {} }'
Sending Logstash's logs to /var/log/logstash which is now configured via log4j2.properties
The stdin plugin is now waiting for input:
hello world
2017-02-21T08:23:56.878Z localhost.localdomain hello world
1.執(zhí)行l(wèi)ogstash -e 'input { stdin { } } output { stdout {} }'
2.-e 參數(shù)允許Logstash直接通過命令行接受設(shè)置
3.無論我們輸入什么字符岖圈,Logstash都會按照某種格式來返回我們輸入的字符
在output中加入codec可以改變輸出變現(xiàn)
[root@localhost logstash]# bin/logstash -e 'input { stdin { } } output { stdout { codec => rubydebug } }'
Sending Logstash's logs to /var/log/logstash which is now configured via log4j2.properties
The stdin plugin is now waiting for input:
hello world again
{
"@timestamp" => 2017-02-21T08:30:58.821Z,
"@version" => "1",
"host" => "localhost.localdomain",
"message" => "hello world again"
}
驗證數(shù)據(jù)是否發(fā)送到Elasticsearch
[root@localhost logstash]# bin/logstash -e 'input { stdin { } } output { elasticsearch { hosts => ["172.16.24.105:9200"] } }'
Sending Logstash's logs to /var/log/logstash which is now configured via log4j2.properties
The stdin plugin is now waiting for input:
test send elasticsearch
1.output里面配置elasticsearch的地址
2.輸入數(shù)據(jù)之后腺占,logstash會像之前那樣處理數(shù)據(jù)憨奸,但是此次看不到輸出(沒有配置stdout)
3.curl 'http://localhost:9200/_search?pretty'--查看ES是否接受到了數(shù)據(jù)
多重輸出:數(shù)據(jù)保存到ES纱烘,同時在控制臺顯示
bin/logstash -e 'input { stdin { } } output { elasticsearch { hosts => ["172.16.24.105:9200"] } stdout { codec => rubydebug}}'