Have a new issue, bro. The name of some fields contains special characters like,
"metadata": {"codecname": "MPEG-4 Audio", "xap/1.0/mm/xmpmm:pantry[2]/xmptpg:npages": "1", "xap/1.0/mm/xmpmm:history[9]/stevt:changed": "/", "createdate": "2022-04-27T14:56:41+01:00", "xap/1.0/mm/xmpmm:pantry[52]/tiff:make": "Canon", "xap/1.0/mm/xmpmm:pantry[4]/xmptpg:npages": "1", "codec": "mp4a", "rating": "0", "xap/1.0/mm/xmpmm:history[6]/stevt:changed": "/", "framewidth (pixels)": 1920, "datarate (kbps)": 1495, "thumbnails[1]/xmpgimg:width": "256", "dc/elements/1.1/dc:format": "H.264", "filetype": "mp42", "thumbnails[1]/xmpgimg:format": "JPEG", "minutes": 0, "xap/1.0/mm/xmpmm:pantry[1]/xmptpg:npages": "1", "audiosamplerate (khz)": 48, "audiobitrate (kbps)": 317, "filetypedeveloper": "ISO", "streamtype": "audio", "encrypted": 0, "hours": 0, "modifydate": "2022-04-27T14:57:12+01:00", "metadatadate": "2022-04-27T14:57:12+01:00", "thumbnails[1]/xmpgimg:height": "72", "xap/1.0/mm/xmpmm:pantry[3]/xmptpg:npages": "1", "length (hh:mm:ss)": "00:00:44", "xap/1.0/mm/xmpmm:pantry[28]/dc:title[1]": "5L ", "channels": 2, "frameheight (pixels)": 1080, "framerate (frames/sec)": 30, "seconds": 44, "tiff/1.0/tiff:orientation": "1", "streamid": "2", "xap/1.0/mm/xmpmm:history[1]/stevt:changed": "/", "xap/1.0/mm/xmpmm:pantry[52]/aux:lensid": "198"}
This causes <RuntimeError: Invalid FieldReference: xap/1.0/mm/xmpmm:pantry[2]/xmptpg:npages
> error.
How should I handle this field name? I also tried to leave it as a _jsonparsefailure and keep the original message, but my current config failed to parse the ts field. Could you advise?
filter {
json {
source => "message"
}
ruby {
code => '
a = event.get("[msgParts]")
if a
a.each_index { |x|
if a[x]["metadata"]
a[x]["metadata"]["extensionless"] = a[x]["metadata"].delete("")
end
}
event.set("[msgParts]", a)
end
'
}
date {
match => ["ts","YYYY-MM-dd'T'HH:mm:ss.SSSZ","ISO8601"]
target => "@timestamp"
}
if "_jsonparsefailure" in [tags] {
mutate {
add_field => { "ts1" => "" }
}
ruby {
code => '
t = event.get("[ts]")
event.set("[ts1]", t)
'
}
date {
match => ["ts","YYYY-MM-dd'T'HH:mm:ss.SSSZ","ISO8601"]
target => "@timestamp"
}
}
if "_jsonparsefailure" not in [tags] {
mutate { remove_field => ["[event][original]","[message]"] }
}
}
Below is a sample log.
{"guid": "6-WyL_R332XqoIateyxm41pivkPL8ohQ", "msgParts": [{"disposition": "attached", "sizeDecodedBytes": 10184246, "isDeleted": false, "labeledCharset": "", "sandboxStatus": "NOT_SUPPORTED", "detectedExt": "MP4", "md5": "21551aaa91f496f9757b774d07c68af9", "detectedSizeBytes": 10184246, "isVirtual": false, "isCorrupted": false, "detectedCharset": "", "labeledExt": "mp4", "sha256": "7a6fd506e9fec42c7c0ca7b0a4067e64b0858e25bea88f13bb889e3a4c65ee50", "detectedMime": "video/mp4", "labeledMime": "video/mp4", "structureId": "0", "detectedName": "eco refill movie_1.mp4", "isProtected": false, "labeledName": "eco refill movie_1.mp4", "isTimedOut": false, "metadata": {"codecname": "MPEG-4 Audio", "xap/1.0/mm/xmpmm:pantry[2]/xmptpg:npages": "1", "xap/1.0/mm/xmpmm:history[9]/stevt:changed": "/", "createdate": "2022-04-27T14:56:41+01:00", "xap/1.0/mm/xmpmm:pantry[52]/tiff:make": "Canon", "xap/1.0/mm/xmpmm:pantry[4]/xmptpg:npages": "1", "codec": "mp4a", "rating": "0", "xap/1.0/mm/xmpmm:history[6]/stevt:changed": "/", "framewidth (pixels)": 1920, "datarate (kbps)": 1495, "thumbnails[1]/xmpgimg:width": "256", "dc/elements/1.1/dc:format": "H.264", "filetype": "mp42", "thumbnails[1]/xmpgimg:format": "JPEG", "minutes": 0, "xap/1.0/mm/xmpmm:pantry[1]/xmptpg:npages": "1", "audiosamplerate (khz)": 48, "audiobitrate (kbps)": 317, "filetypedeveloper": "ISO", "streamtype": "audio", "encrypted": 0, "hours": 0, "modifydate": "2022-04-27T14:57:12+01:00", "metadatadate": "2022-04-27T14:57:12+01:00", "thumbnails[1]/xmpgimg:height": "72", "xap/1.0/mm/xmpmm:pantry[3]/xmptpg:npages": "1", "length (hh:mm:ss)": "00:00:44", "xap/1.0/mm/xmpmm:pantry[28]/dc:title[1]": "5L ", "channels": 2, "frameheight (pixels)": 1080, "framerate (frames/sec)": 30, "seconds": 44, "tiff/1.0/tiff:orientation": "1", "streamid": "2", "xap/1.0/mm/xmpmm:history[1]/stevt:changed": "/", "xap/1.0/mm/xmpmm:pantry[52]/aux:lensid": "198"}, "textExtracted": "U0NBTEFSKDB4N2YwNzEwMmZhOTMwKQ==\n", "urls": [], "dataBase64": "U0NBTEFSKDB4N2YwN2E2YjM0ZWEwKQ==\n", "isArchive": false}, {"sandboxStatus": "NOT_SUPPORTED", "detectedExt": "JPG", "md5": "32825d23f13ae618fe0802801690274b", "disposition": "attached", "sizeDecodedBytes": 1166579, "isDeleted": false, "labeledCharset": "", "isCorrupted": false, "isVirtual": false, "detectedCharset": "", "detectedSizeBytes": 1166579, "detectedName": "eco refill 3840x1098px-02.jpg", "structureId": "0", "labeledName": "eco refill 3840x1098px-02.jpg", "isProtected": false, "isTimedOut": false, "metadata": {}, "sha256": "cc5c09c4ea143d2a0f03d20ff0edc59f8a3e34f56594105b25e6b124c5b2d7a1", "labeledExt": "jpg", "detectedMime": "image/jpeg", "labeledMime": "image/jpeg", "urls": [], "dataBase64": "U0NBTEFSKDB4N2YwNzEwNTQ1MzAwKQ==\n", "isArchive": false, "textExtracted": "U0NBTEFSKDB4N2YwNzc2NmM4MWY4KQ==\n"}, {"detectedCharset": "", "isVirtual": false, "isCorrupted": false, "detectedSizeBytes": 2363187, "md5": "6d19a5dee9ca5b383f488fbe9404fb9f", "sandboxStatus": "UPLOADED", "detectedExt": "PPTX", "isDeleted": false, "labeledCharset": "", "disposition": "attached", "sizeDecodedBytes": 2363187, "dataBase64": "U0NBTEFSKDB4N2YwNzEwNTNlNTEwKQ==\n", "isArchive": false, "urls": [], "textExtracted": "U0NBTEFSKDB4N2YwNzJjYmE4ZGUwKQ==\n", "isTimedOut": false, "metadata": {"edittime": 44, "author": "Ben Edwards", "shareddoc": 0, "revnumber": "4", "parcount": 0, "presentationtarget": "Widescreen", "codepage": 65001, "scalecrop": 0, "titlesofparts": "Arial;Calibri;Calibri Light;Office Theme;PowerPoint Presentation;PowerPoint Presentation", "lastauthor": "Ben Edwards", "title": "PowerPoint Presentation", "wordcount": 0, "slidecount": 2, "mmclips": 0, "hyperlinkschanged": 0, "appversion": "16.0000", "headingpairs": "Fonts Used;3;Theme;1;Slide Titles;2", "appname": "Microsoft Office PowerPoint", "linksdirty": 0, "hiddencount": 0, "notecount": 0}, "structureId": "0", "detectedName": "social posts eco refill.pptx", "isProtected": false, "labeledName": "social posts eco refill.pptx", "sha256": "95ce5a603f830fe8dfbba88865714e5407837d93e844010f7509a8e1cd04ce74", "labeledExt": "pptx", "detectedMime": "application/vnd.openxmlformats-officedocument.presentationml.presentation", "labeledMime": "application/vnd.openxmlformats-officedocument.presentationml.presentation"}], "ts": "2022-05-19T05:52:30.297121-0400"}