docker-compose syslog driver loggly multi-line log

2019-08-21 07:24发布

问题:

I'm trying to configure loggly logging for Node.js microservices deployed in a docker-machine.

I've configured the logging driver in my docker-compose.yml like so...

logging:
  driver: "syslog"
  options:
    tag: "my-app-name"

I've configured the docker-machine to send logs to loggly, by doing the following...

curl -O https://www.loggly.com/install/configure-linux.sh
sudo bash configure-linux.sh -a SUBDOMAIN -t TOKEN -u USERNAME

... as per these instructions https://www.loggly.com/docs/configure-syslog-script/

My apps are now sending logs to loggly. However the multi-line log entries are coming through as multiple log entries. This makes it extremely difficult to work with stack traces etc.

Is there a way to configure docker-compose, syslog, rsyslogd etc. to keep multi-line entries together?

If I check /var/log/syslog directly, the log entries look like so...

Sep 13 08:26:32 [ip_address] my-app-name[1082]: WARNING: Creating a duplicate database object for the same connection.
Sep 13 08:26:32 [ip_address] my-app-name[1082]:     at Object.<anonymous> (/app/my-app-name/db.js:14:10)
...
Sep 13 08:26:32 [ip_address] my-app-name[1082]:     at Object.<anonymous> (/app/my_routes.js:3:28)

At the moment this creates a loggly entry for each line, so it loses all context.

I'm hoping there's some way that rsyslogd can figure out that all of these lines (having an identical prefix) should be sent as a single log entries to loggly.

Is this possible to do using the syslog driver? I would prefer to not have to add the logging directly into the apps themselves.