我想使用Logstash将数据parse
到Elasticsearch。到目前为止,这很好用,但是当我尝试解析JSON文件时,Logstash不会做任何事情。我可以毫无异常(exception)地启动Logstash,但它不会解析任何内容。
我的配置有问题吗? JSON文件的路径正确。
我的JSON:
{
"stats": [
{
"liveStatistic": {
"@scope": "21",
"@scopeType": "foo",
"@name": "minTime",
"@interval": "60",
"lastChange": "2011-01-11T15:19:53.259+02:00",
"start": "2011-01-18T14:19:48.333+02:00",
"unit": "s",
"value": 10
}
},
{
"liveStatistic": {
"@scope": "26",
"@scopeType": "bar",
"@name": "newCount",
"@interval": "60",
"lastChange": "2014-01-11T15:19:59.894+02:00",
"start": "2014-01-12T14:19:48.333+02:00",
"unit": 1,
"value": 5
}
},
...
]
}
我的Logstash代理配置:
input {
file {
path => "/home/me/logstash-1.4.2/values/stats.json"
codec => "json"
start_position => "beginning"
}
}
output {
elasticsearch {
host => localhost
protocol =>"http"
}
stdout {
codec => rubydebug
}
}
最佳答案
您应该在输入中添加以下行:
start_position => "beginning"
还要将完整文档放在一行上,并可能在文档周围添加{}以使其成为有效的json文档。
关于json - Logstash-无法解析JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24805746/