파일에서 json 콘텐츠를 추출해야하는 로그 파일이 하나 있는데 logstash json 필터를 사용하여 구문 분석해야합니다. 내가 한 grok 패턴을 썼지 만 제대로 작동하지 않습니다. 아래는 내 로그 파일입니다.grok/정규식을 사용하여 로그 파일에서 json 값을 분할하는 방법
2016-12-18 12:13:52.313 -08:00 [Information] 636176600323139749 1b2c4c40-3da6-46ff-b93f-0eb07a57f2a3 18 - API: GET https://aaa.com/o/v/S?$filter=uid eq '9'&$expand=org($filter=org eq '0')
{
"Id": "1b",
"App": "D",
"User": "",
"Machine": "DC",
"RequestIpAddress": "xx.xxx.xxx",
"RequestHeaders": {
"Cache-Control": "no-transform",
"Connection": "close",
"Accept": "application/json"
},
"RequestTimestamp": "2016-12-18T12:13:52.2609587-08:00",
"ResponseContentType": "application/json",
"ResponseContentBody": {
"@od","value":[
{
"uid":"","sId":"10,org":[
{
"startDate":"2015-02-27T08:00:00Z","Code":"0","emailId":"[email protected]"
}
]
}
]
},
"ResponseStatusCode": 200,
"ResponseHeaders": {
"Content-Type": "application/json;"
},
"ResponseTimestamp": "2016-12-18T12:13:52.3119655-08:00"
}
내 grok 수 패턴
grok {
match => [ "message","%{TIMESTAMP_ISO8601:exclude}%{GREEDYDATA:exclude1}(?<exclude2>[\s])(?<json_value>[\W\w]+)"]
}
패턴을 캡처하고 싶지 않다면 "exclude", "exclude1"등의 필요없이 이름을 그대로 둘 수 있습니다. –