mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-19 04:30:43 +01:00
mmexternal: support "json" inbound message passing
This commit is contained in:
parent
40c02e2249
commit
f860025bd4
11
plugins/external/INTERFACE.md
vendored
11
plugins/external/INTERFACE.md
vendored
@ -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.
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user