【发布时间】:2018-11-05 16:18:01
【问题描述】:
我在使用 logstash 将以下原始数据引入 elasticsearch 时遇到问题。抽象了下面的原始数据,希望 JSON 插件可以工作,但目前没有。我查看了其他有关 json 的帖子无济于事。
{
"offset": "stuff",
"results": [
{
"key": "value",
"key1": null,
"key2": null,
"key3": "true",
"key4": "value4",
"key4": [],
"key5": value5,
"key6": "value6",
"key7": "value7",
"key8": value8,
"key9": "value9",
"key10": null,
"key11": null,
"key12": "value12",
"key13": "value13",
"key14": [],
"key15": "key15",
"key16": "value16",
"key17": "value17",
"key18": "value18",
"key19": "value19"
},
{
"key20": "value20",
"key21": null,
"key22": null,
"key23": "value23",
"key24": "value24",
<etc.>
我当前的配置文件:
input {
file {
codec => multiline
{
pattern => '^\{'
negate => true
what => previous
}
#type => "json"
path => <my path>
sincedb_path => "/dev/null"
start_position => "beginning"
}
}
#filter
#{
# json {
# source => message
# remove_field => message
# }
#}
filter
{
mutate
{
replace => [ "message", "%{message}}" ]
gsub => [ 'message','\n','']
}
if [message] =~ /^{.*}$/
{
json { source => message }
}
}
output {
#stdout { codec => rubydebug }
stdout { codec => json }
}
我收到一个很长的错误,我无法阅读,因为它充满了 " \"key10\": null,\r \"key11\": \"value11\",\r
等等
有谁知道我做错了什么或如何更好地看到我的错误?这是有效的 json,但也许我将我的正则表达式用于多行编解码器错误。
【问题讨论】:
-
看到了这个提示,jsonlint.com 我的完整代码验证了它是 json 所以希望 json 插件如果使用正确的话可以工作,只是无法弄清楚如何。
标签: json elasticsearch logstash