我正在使用Bunyan和bunyas-lumberjack将我的日志发送到log stash,并在弹性搜索中对它们进行索引。我面临的问题是,当我过滤日志时:我使用的是Logstash的基本过滤器:
filter {
if [type == "json"]{
json {
source => "message"
}
}
}这会将来自bunyan的JSON放入source.message字段,并在弹性搜索中对其进行索引。如何将bunyan中的每个字段索引到特定的弹性搜索字段中,以便在Kibana中进行搜索或使用?
我附上我现在所获得的和我想要获得的作为例子。目前:
{
"_index": "logstash-2015.10.26",
"_type": "json",
"_id": "AVCjvDHWHiX5VLMgQZIC",
"_score": null,
"_source": {
"message": "{\"name\":\"myLog\",\"hostname\":\"atnm-4.local\",\"pid\":6210,\"level\":\"error\",\"message\":\"This should work!\",\"@timestamp\":\"2015-10-26T10:40:29.503Z\",\"tags\":[\"bunyan\"],\"source\":\"atnm-4.local/node\"}",
"@version": "1",
"@timestamp": "2015-10-26T10:40:31.184Z",
"type": "json",
"host": "atnm-4.local",
"bunyanLevel": "50"
},招聘:
{
"_index": "logstash-2015.10.26",
"_type": "json",
"_id": "AVCjvDHWHiX5VLMgQZIC",
"_score": null,
"_source": {
"message": {
"name": example,
"hostname": example,
"etc": example发布于 2015-11-07 05:28:07
logstash中的每个输入可以有不同的编解码器和类型。在您的例子中,如果您想要索引bunyan和syslog,您将拥有两个具有两种不同类型的输入。syslog的编解码器是"plain",bunyan的编解码器是"json“。您不需要对bunyan消息进行任何筛选。json将被解析,字段将自动显示。您必须使用筛选器来解析syslog输入。
https://stackoverflow.com/questions/33343884
复制相似问题