eSX via rsyslog
2018-08-07 09:26:06 UTC
Hi all
When the log message part is JSON, a message processing like:
parse json with mmjsonparser,
process variables in $!.
unset variables, e.g. unset $!foo!bar;
Alright, send a processed message to next action.
But there were some variables unset, I don't want them to appear in next
action.
So I have to format the message from $! but not $msg.
like:
template (name = "next_action_msg" type = "string" string = "%$!%\n")
There's nothing wrong with it, but a bit flaw.
The fields in message from $! was separated by SPACE. like:
{"foo": {"bar": "hello"}}
but not:
{"foo":{"bar":"hello"}}
A space separated json message could waste more disk space and DB.
It's acceptable, but not necessary for machine readable message.
For human readable, extra spaces added is not enough also, pretty-formated
messages are needed.
There is a low cost improvement method to avoid it.
The json is converted to string in msg.c:getJSONPropVal(), by
calling json_object_get_string().
json_object_get_string() will add space automaticlly, by calling
json_object_to_json_string_ext() with flag JSON_C_TO_STRING_SPACED.
json_object_to_json_string_ext() can accept more flags,
json_object_to_json_string_ext(field, JSON_C_TO_STRING_SPACED) ==
json_object_get_string(field)
json_object_to_json_string_ext(field, JSON_C_TO_STRING_PLAIN) means no more
extra space added.
Any ideas?
Thanks
When the log message part is JSON, a message processing like:
parse json with mmjsonparser,
process variables in $!.
unset variables, e.g. unset $!foo!bar;
Alright, send a processed message to next action.
But there were some variables unset, I don't want them to appear in next
action.
So I have to format the message from $! but not $msg.
like:
template (name = "next_action_msg" type = "string" string = "%$!%\n")
There's nothing wrong with it, but a bit flaw.
The fields in message from $! was separated by SPACE. like:
{"foo": {"bar": "hello"}}
but not:
{"foo":{"bar":"hello"}}
A space separated json message could waste more disk space and DB.
It's acceptable, but not necessary for machine readable message.
For human readable, extra spaces added is not enough also, pretty-formated
messages are needed.
There is a low cost improvement method to avoid it.
The json is converted to string in msg.c:getJSONPropVal(), by
calling json_object_get_string().
json_object_get_string() will add space automaticlly, by calling
json_object_to_json_string_ext() with flag JSON_C_TO_STRING_SPACED.
json_object_to_json_string_ext() can accept more flags,
json_object_to_json_string_ext(field, JSON_C_TO_STRING_SPACED) ==
json_object_get_string(field)
json_object_to_json_string_ext(field, JSON_C_TO_STRING_PLAIN) means no more
extra space added.
Any ideas?
Thanks
--
eSX
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.
eSX
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.