Logstash - 从 json 文件中删除深层字段
Logstash - remove deep field from json file
我有 JSON 个文件,要通过 logstash 发送到 ES。我想删除 JSON 中的 1 个字段(它是深字段)- 仅当值为 NULL 时。
部分JSON是:
"input": {
"startDate": "2015-05-27",
"numberOfGuests": 1,
"fileName": "null",
"existingSessionId": "XXXXXXXXXXXXX",
**"radius": "null",**
"nextItemReference": "51",
"longitude": -99.12,
"endDate": "2015-05-29",
"thumbnailHeight": 200,
"thumbnailWidth": 300,
"latitude": 19.42,
"numOfRooms": "1"
},
logstash.conf
文件中的部分是:
if [input.radius] == "null" {
mutate {
remove_field => [ "input.radius" ]
}
}
这当然在过滤器里面。
如果值为空,如何删除该字段?
嵌套字段未通过 [name.subfield]
引用,而是通过 [field][subfield]
引用。这应该适合你:
if [input][radius] == "null" {
mutate {
remove_field => [ "[input][radius]" ]
}
}
请注意,如果没有 "input" 字段,[input][radius]
引用将创建一个空的 "input" 字典。为避免这种情况,您可以这样做:
if [input] and [input][radius] == "null" {
mutate {
remove_field => [ "[input][radius]" ]
}
}
有关详细信息和更多示例,请参阅 Logstash documentation。
我有 JSON 个文件,要通过 logstash 发送到 ES。我想删除 JSON 中的 1 个字段(它是深字段)- 仅当值为 NULL 时。
部分JSON是:
"input": {
"startDate": "2015-05-27",
"numberOfGuests": 1,
"fileName": "null",
"existingSessionId": "XXXXXXXXXXXXX",
**"radius": "null",**
"nextItemReference": "51",
"longitude": -99.12,
"endDate": "2015-05-29",
"thumbnailHeight": 200,
"thumbnailWidth": 300,
"latitude": 19.42,
"numOfRooms": "1"
},
logstash.conf
文件中的部分是:
if [input.radius] == "null" {
mutate {
remove_field => [ "input.radius" ]
}
}
这当然在过滤器里面。
如果值为空,如何删除该字段?
嵌套字段未通过 [name.subfield]
引用,而是通过 [field][subfield]
引用。这应该适合你:
if [input][radius] == "null" {
mutate {
remove_field => [ "[input][radius]" ]
}
}
请注意,如果没有 "input" 字段,[input][radius]
引用将创建一个空的 "input" 字典。为避免这种情况,您可以这样做:
if [input] and [input][radius] == "null" {
mutate {
remove_field => [ "[input][radius]" ]
}
}
有关详细信息和更多示例,请参阅 Logstash documentation。