10,431
社区成员




我用logstash结构化一组日志信息时,它显示
[2022-08-05T14:42:04,829][WARN ][logstash.outputs.elasticsearch][main][210b40b160d8f8127448631ee76ce559a4f4b1f8760100d30e898a1cedf45979] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"vmkernel_log", :routing=>nil}, {"目标"=>"vmhba2:C0:T5:L0", "函数指令"=>"nmpPathClaimEnd:1206:", "时间戳"=>"2022-06-17T12:42:59.628Z", "log"=>{"file"=>{"path"=>"/var/log/vmkernel.log"}}, "@version"=>"1", "event"=>{"original"=>"2022-06-17T12:42:59.628Z cpu19:2179328)WARNING: NMP: nmpPathClaimEnd:1206: Device, seen through path vmhba2:C0:T5:L0 is not registered (no active paths)"}, "类型"=>"Device,", "方法"=>"NMP:", "CPU进程"=>"cpu19:2179328)WARNING:", "@timestamp"=>2022-08-05T06:42:04.616139Z, "message"=>["2022-06-17T12:42:59.628Z", "cpu19:2179328)WARNING:", "NMP:", "nmpPathClaimEnd:1206:", "Device,", "seen", "through", "path", "vmhba2:C0:T5:L0", "is", "not", "registered", "(no", "active", "paths)"], "host"=>{"name"=>"k8s-08"}, "type"=>"vmkernel"}], :response=>{"index"=>{"_index"=>"vmkernel_log", "_id"=>"QNW9bIIBMit-ig-KWax8", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"mapper [message] cannot be changed from type [date] to [text]"}}}}
elasticsearch中虽然创建了对应文档,但文档中没有事件。
但如果用标准输入的话,每次输入一条日志,却可以正常解析。
错误日志最后给出了报错原因:mapper [message] cannot be changed from type [date] to [text]
请问该如何修改不会让它报错?
感觉是你的有些文档的 date 字段不是可以辨识的 date 字段,从而被解析为 text 类型。你如果输入一条日志,这个日志的格式可能是正确的,就没有问题,但是你不能保证所有的文档的格式都是一样的。这个你可以通过错误日志来进行判断。