How do you properly format json messages and send them over amqp with syslog-ng?
The json format should look something like this.
{"log":"This is the error message...", "date":"xxx", "source":"xxx"}
The problem I have is that the message is not always a valid json string.
e.g.
"log":"This is a "serious" error message."
How would I go about escaping the message?
My syslog-ng configuration looks something like this.
destination d_amqp {
amqp(
vhost("/")
host("127.0.0.1")
port(5672)
username("guest") # required option, no default
password("guest") # required option, no default
exchange("syslog")
exchange_type("header")
routing_key("my-routing-key")
body("\{\"log\":\"${MSG}\"\}")
persistent(yes)
value-pairs(
scope("selected-macros" "nv-pairs" "sdata")
)
);
};
This is just an example, as I don't have the actual configuration in front of me right now.