Using "converter" to preprocess JSON -> JSON logs #1226
-
I often interact with JSON logs having this structure {"context": "body_bytes_sent":0} But, when these logs are shipped to New Relic, all the nesting is removed by changing it to flat structure like so {"context.body_bytes_sent":0} Instead of having to write and maintain 2 different format definitions, I was thinking to use conversion feature. However, not sure lnav can do such thing. Whole thing is a bit intimidating to me, because it seems it's designed for a binary conversion. Could you confirm automatic JSON->JSON conversion here is possible and shine a bit more light here how would I go about it? I've tried something like "converter": {
"header": {
"expr": {
"newrelic": "decode(:header, 'hex') LIKE '%context.%'",
"size": 128
}
},
"command": "test.sh"
}, But test.sh is never executed (I know because its contents are |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
First, the "size" property should be in the "header" and not the "expr" object. You can pass I changed the converter SQL expression so it would match the "newrelic": "decode(:header, 'hex') LIKE '%\"context\"%'" |
Beta Was this translation helpful? Give feedback.
First, the "size" property should be in the "header" and not the "expr" object. You can pass
-W
to lnav to get a warning.I changed the converter SQL expression so it would match the
dev.log.bak2.json
file you sent earlier and it seemed to "work". As in, lnav complains that it couldn't find thetest.sh
converter script. The expression looked like the following after my change: