【发布时间】:2019-01-18 20:35:09
【问题描述】:
我的设置如下:
- 应用程序正在将日志写入文件:file.json。
- 文件中的每一行都包含一条我想要存储在 ES 索引中的 json 记录。
- 我已将 logstash 配置为从此文件中读取数据并将数据存储在 ES 上。
但是 logstash 并没有将完整的 json 记录作为源存储在 ES 中。而是将完整的 json 放在一个字段中。
更多详情:
Logstash 配置:
input {
file {
type => "json"
path => "file.json"
start_position => beginning
}
}
output {
elasticsearch {
hosts => [ "10.1.1.1:9200" ]
index => "index-name"
}
}
文件.json:
{"name":"John", "age":31, "city":"Abc"}
在 ES 中存储的记录:
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "index_name",
"_type" : "doc",
"_id" : "eHD8KGUBy7HkgIAhGQln",
"_score" : 1.0,
"_source" : {
"type" : "json",
"host" : "qa-box",
"@version" : "1",
"message" : "{name:John,age:31,city:Abc}",
"@timestamp" : "2018-08-11T12:35:34.184Z",
"path" : "file.json"
}
}
]
}
【问题讨论】:
标签: elasticsearch logstash elastic-stack