官方文檔:
doc:http://udn.yyuap.com/doc/logstash-best-practice-cn/filter/index.html
code:https://github.com/elastic/logstash
一. 學習插件 Logstash HTTP input plugin
1 修改配置文件
input
{
http
{
host => "127.0.0.1"
port => 31311 #接受http請求
additional_codecs => {"application/json"=>"json"}
codec => "plain"
threads => 4
ssl => false
}
}
filter
{
#過濾不需要請求
}
output
{
stdout { codec => rubydebug}
}
logstash -f /home/wangchuanyi/ob_rel/logstash-5.4.1/config/logstashHttp.conf
2 curl測試
curl -H "content-type: application/json"
-XPUT 'http://127.0.0.1:31311/test/'
-d '{ "name" : "troy", "pwd" : "今天發(fā)蘋果吃了 " }'
查看logstash日志:
logstash輸出到屏幕上.png
總結(jié):Flume 和logstash 都可以接受http請求 前者寫代碼 后者通過配置來控制
參考
1 https://www.elastic.co/blog/introducing-logstash-input-http-plugin#sthash.alyYTzAS.dpbs
2 http://www.cnblogs.com/xing901022/p/5256227.html