diff --git a/plugins/external/INTERFACE.md b/plugins/external/INTERFACE.md index a9ef7c8b0..69c771b60 100644 --- a/plugins/external/INTERFACE.md +++ b/plugins/external/INTERFACE.md @@ -73,10 +73,13 @@ External Message Modification Modules The external plugin will use stdin to receive the message that it potentially can modify. The message will be LF-terminated, and no LF must be present within the message itself. By default, the MSG part of the message is provided as input. -The "interface.input" parameter can be used to modify this. It currently support -either "msg" (the default) or "rawmsg", which is the complete message (including -header) as received by rsyslog. In the future, the value "json" will permit to -receive a JSON encoded copy of the message. +The "interface.input" parameter can be used to modify this. It may has the following +values: + +* "msg" (the default) +* "rawmsg", which is the complete message (including header) as received by rsyslog +* "json", which is the complete message object (with all properties broken + out) as a JSON object string. This is the "jsonmesg" dynamic message property. **Note**: if multi-line messages are to be processed, JSON representation **must** be used, otherwise errors will happen. diff --git a/plugins/mmexternal/mmexternal.c b/plugins/mmexternal/mmexternal.c index a9e882735..149cf6757 100644 --- a/plugins/mmexternal/mmexternal.c +++ b/plugins/mmexternal/mmexternal.c @@ -440,16 +440,17 @@ callExtProg(wrkrInstanceData_t *__restrict__ const pWrkrData, msg_t *__restrict_ int writeOffset; char errStr[1024]; uchar msgStr[4096]; - uchar *inputstr; /* string to be processed by external program */ + const uchar *inputstr; /* string to be processed by external program */ DEFiRet; if(pWrkrData->pData->inputProp == INPUT_MSG) { inputstr = getMSG(pMsg); lenWrite = getMSGLen(pMsg); } else if(pWrkrData->pData->inputProp == INPUT_RAWMSG) { - getRawMsg(pMsg, &inputstr, &lenWrite); + getRawMsg(pMsg, (uchar**)&inputstr, &lenWrite); } else { - DBGPRINTF("DDDDD: JSON mode not yet supported!\n"); + inputstr = msgGetJSONMESG(pMsg); + lenWrite = strlen((const char*)inputstr); } lenWrite = snprintf((char*)msgStr, sizeof(msgStr), "%s\n", inputstr); // TODO: make this more solid! writeOffset = 0; diff --git a/runtime/msg.c b/runtime/msg.c index d22099e6d..5d18163ae 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1935,8 +1935,8 @@ void MsgSetParseSuccess(msg_t * const pMsg, int bSuccess) /* return full message as a json string */ -static const uchar* -getJSONMESG(msg_t *__restrict__ const pMsg) +const uchar* +msgGetJSONMESG(msg_t *__restrict__ const pMsg) { struct json_object *json; struct json_object *jval; @@ -3044,7 +3044,7 @@ uchar *MsgGetProp(msg_t *__restrict__ const pMsg, struct templateEntry *__restri pRes = (uchar*)getMSGID(pMsg); break; case PROP_JSONMESG: - pRes = (uchar*)getJSONMESG(pMsg); + pRes = (uchar*)msgGetJSONMESG(pMsg); break; #ifdef USE_LIBUUID case PROP_UUID: diff --git a/runtime/msg.h b/runtime/msg.h index 87142f808..ec22545f6 100644 --- a/runtime/msg.h +++ b/runtime/msg.h @@ -194,6 +194,7 @@ rsRetVal msgAddJSON(msg_t *pM, uchar *name, struct json_object *json); rsRetVal MsgGetSeverity(msg_t *pThis, int *piSeverity); rsRetVal MsgDeserialize(msg_t *pMsg, strm_t *pStrm); rsRetVal MsgSetPropsViaJSON(msg_t *__restrict__ const pMsg, const uchar *__restrict__ const json); +const uchar* msgGetJSONMESG(msg_t *__restrict__ const pMsg); /* TODO: remove these five (so far used in action.c) */ uchar *getMSG(msg_t *pM);