你可以的,加油

ElasticSearch如何获取来自LogStash的采集数据

Elasticsearch | 作者 RekaDowney | 发布于2016年07月14日 | 阅读数:5657

已知:
    0、LogStashES 的版本都是 2.3.1
    1、LogStash 采集数据并发往 ES 是通过 _bulk API POST 请求完成的;
    2、在 ES 的源码中,已经获取到了 org.jboss.netty.handler.codec.http.HttpRequest 对象;
 
问题:
    1、LogStash 发送到 ES 的数据格式是怎样的?
    2、如何在 ES 的源码中,通过 HttpRequest 对象获取来自 _bulk API 的数据? 
示例:
    这里使用 curl 演示一下 _bulk API  以及问题2想要获取的内容
curl -i -XPOST 'http://localhost:9200/_bulk/?pretty' -d '
{ "delete" : {"_index" : "test", "_type" : "employee", "_id" : "3" } }
{ "create" : {"_index" : "test", "_type" : "employee", "_id" : "3"} }
{ "first_name" : "Reka", "last_name" : "Downey", "age" : 22, "about" : "I like new things!", "interests" : ["sport", "read"] }
{ "index" : {"_index" : "test", "_type" : "employee"} }
{ "first_name" : "Lily", "last_name" : "Smith", "age" : 23, "about" : "I like swimming!", "interests" : ["swim"] }
{ "update" : {"_index" : "test", "_type" : "employee", "_id" : "3"} }
{ "docs" : {"age" : 24} }
'
问题2想要获取的内容是:
   
    { "delete" : {"_index" : "test", "_type" : "employee", "_id" : "3" } }
{ "create" : {"_index" : "test", "_type" : "employee", "_id" : "3"} }
{ "first_name" : "Reka", "last_name" : "Downey", "age" : 22, "about" : "I like new things!", "interests" : ["sport", "read"] }
{ "index" : {"_index" : "test", "_type" : "employee"} }
{ "first_name" : "Lily", "last_name" : "Smith", "age" : 23, "about" : "I like swimming!", "interests" : ["swim"] }
{ "update" : {"_index" : "test", "_type" : "employee", "_id" : "3"} }
{ "docs" : {"age" : 24} }
已邀请:

nodexy - Another developer !

赞同来自:

有一个技巧: es提供了HTTP服务,你可以加一个拦截器,把所有 bulk 的请求拦截下来,这样就记录到了 bulk 提交的POST数据。

三斗室 - ELK

赞同来自:

Logstash2.3发给es的数据就是标准的HTTP方式bulk接口。
不过你是要干嘛?

要回复问题请先登录注册