![](/img/trans.png)
[英]logstash json filter not parsing. getting _jsonparsefailure although the json is correct
[英]logstash json filter not parsing fields getting _jsonparsefailure
嗨,我正在嘗試解析一個json文件。 我已經嘗試過使用stackoverflow的建議進行故障排除(底部的鏈接),但是沒有一個對我有用。 我希望有人對我犯的一個愚蠢的錯誤有所了解。
我試過僅使用json編解碼器,僅使用json過濾器以及兩者。 由於某種原因,我仍然收到此_jsonparsefailure。 我該怎么做才能使它正常工作?
提前致謝!
我的json文件:
{
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [
{
"startedDateTime": "2015-10-13T20:28:46.081Z",
"id": "page_1",
"title": "https://demo.com",
"pageTimings": {
"onContentLoad": 377.8560000064317,
"onLoad": 377.66200001351535
}
},
{
"startedDateTime": "2015-10-13T20:29:01.734Z",
"id": "page_2",
"title": "https://demo.com",
"pageTimings": {
"onContentLoad": 1444.0670000039972,
"onLoad": 2279.20100002666
}
},
{
"startedDateTime": "2015-10-13T20:29:04.014Z",
"id": "page_3",
"title": "https://demo.com",
"pageTimings": {
"onContentLoad": 1802.0240000041667,
"onLoad": 2242.4060000048485
}
},
{
"startedDateTime": "2015-10-13T20:29:09.224Z",
"id": "page_4",
"title": "https://demo.com",
"pageTimings": {
"onContentLoad": 274.82699998654425,
"onLoad": 1453.034000005573
}
}
]
}
}
我的logstash conf:
input {
file {
type => "json"
path => "/Users/anonymous/Documents/demo.json"
start_position => beginning
}
}
filter{
json{
source => "message"
}
}
output {
elasticsearch { host => localhost protocol => "http" port => "9200" }
stdout { codec => rubydebug }
}
我希望從logstash獲得的輸出有線索:
Trouble parsing json {:source=>"message", :raw=>" \"startedDateTime\": \"2015-10-19T18:05:37.887Z\",", :exception=>#<TypeError: can't convert String into Hash>, :level=>:warn}
{
"message" => " {",
"@version" => "1",
"@timestamp" => "2015-10-26T20:05:53.096Z",
"host" => "15mbp-09796.local",
"path" => "/Users/anonymous/Documents/demo.json",
"type" => "json",
"tags" => [
[0] "_jsonparsefailure"
]
}
我在這里JSONLint測試我的JSON。 也許這可以解決您的問題。 我得到的錯誤是它期望字符串。
看來您最后沒有多余的逗號(',')。 刪除它或在此之后添加另一個JSON變量。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.