官方文档:
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" : "今天发苹果吃了 " }'
查看logstash日志:
总结: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