ProTip: 5.x ODS formatting default object.record for transfer


hello friends:

i recently had need to send HTTP data off-box and needed to format it in a comma separated Key=Value syslog payload.

because HTTP.record already had all the data i needed, it was qqqqqquick exercise in looping to format the whole thing for consumption on the far side:

msg = '', sep = '';
for (var key in obj) {
    if (obj.hasOwnProperty(key)) {
        msg += sep + key + "=" + obj[key];
        sep = ', ';

wahoo - a single string consumable in the rsyslogger of your choice…

you could probably come up with a series of regexs that could do a similar thing with a JSON.stringify of the object, but it could get mightily complex to replace it correctly for a straigth-up send fo rsyslog wothout a JSON parser on the other end…