[英]Dynamic Index in ElasticSearch from Logstash
我在logstash中进行以下配置,从而可以根据收到的输入JSON将动态“ document_type”创建到ES:
elasticsearch {
hosts => ["localhost:9200"]
index => "queuelogs"
document_type => "%{action}"
}
在这里,“ action ”是我在JSON中收到的参数,并且根据收到的不同操作创建了不同的document_type。
现在,我希望对索引创建执行相同的操作,例如:
elasticsearch {
hosts => ["localhost:9200"]
index => "%{logtype}"
document_type => "%{action}"
}
在这里,“ logtype ”是我在JSON中收到的参数。
但是以某种方式在ES中,它仅将索引创建为“%{logtype}”,而不是根据实际logtype值创建索引。
输入的JSON如下所示:
{
"action": "UPLOAD",
"user": "123",
"timestamp": "2016 Jun 14 12:00:12",
"data": {
"file_id": "2345",
"file_name": "xyz.pdf"
},
"header": {
"proj_id": "P123",
"logtype": "httplogs"
},
"comments": "Check comments"
}
在这里,我尝试通过以下方式生成索引:
index =>“%{logtype}”
索引=>“%{header.logtype}”
但是在两种情况下,Logstash都不会替换JSON中的logtype的实际值。
您需要像这样指定它:
elasticsearch {
hosts => ["localhost:9200"]
index => "%{[header][logtype]}"
document_type => "%{action}"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.