logstash의 http 플러그인을 사용하여 서비스 요청 추적을 JSON Array 형식으로 구현하려고합니다.LogStash로 json 배열 구문 분석 문제 발생
오류 :
:message=>"gsub mutation is only applicable for Strings, skipping", :field=>"message", :value=>nil, :level=>:debug, :file=>"logstash/filters/mutate.rb", :line=>"322", :method=>"gsub"}
:message=>"Exception in filterworker", "exception"=>#<LogStash::ConfigurationError: Only String and Array types are splittable. field:message is of type = NilClass>
내 JSON 배열은 다음과 같습니다
{
"data": [
{
"appName": "DemoApp",
"appVersion": "1.1",
"deviceId": "1234567",
"deviceName": "moto e",
"deviceOSVersion": "5.1",
"packageName": "com.DemoApp",
"message": "testing null pointer exception",
"errorLog": "null pointer exception"
},
{
"appName": "DemoApp",
"appVersion": "1.1",
"deviceId": "1234567",
"deviceName": "moto e",
"deviceOSVersion": "5.1",
"packageName": "com.DemoApp",
"message": "testing illegal state exception",
"errorLog": "illegal state exception"
}
]
}
내 logstash의 설정은 다음과 같습니다
우리는 JSON 배열을 구문 분석하려고 시도 할 때 다음과 같은 오류를 얻고있다
input {
http {
codec => "plain"
}
}
filter{
json {
source => "message"
}
mutate { gsub => [ "message", "},", "shr" ] }
split {
terminator => "shr"
field => "data"
}
}
}
output {
stdout { codec => "json" }
gelf{
host => localhost
facility => "%{type}"
level =>["%{SeverityLevel}", "INFO"]
codec => "json"
}
file{
path => "/chroot/result.log"
}
}
도움이 될 것입니다.
정규식에서 특수 문자를 이스케이프 처리한다고 생각합니다 :'mutate {gsub => [ "message", "\} \, \ r \ n \ r \ n \ {", "\} shr \ {" }' – Kadir
@ 카디르 나는 당신의 위의 제안을 시도했다. 그러나 나는 여전히 같은 실수를하고있다. –