Rancher 2.0 pods rsyslog to file

Hi,

I’m trying to output pod logs to file using rsyslog in a format similar to the /var/log/pods layout.
The thing I’m trying to accomplish is logging to an external rsyslog host which writes the logs to files on disk.

First of all I keep getting two lines per container log, one for the message and another one for metadata. Syslog simply throws both of these in one log wile.

Second issue is that the hostname will either result in the kubernetes host or the hostname of the rancher-fluentd container but never the actual container hostname since that is not the host providing the log stream.

I’ve tried using fluentd instead of rsyslog but I’m quite a newbie regarding fluentd and haven’t been able to find a way of writing logs to file using the variables from the metadata.

My ultimate goal would be to divide logs of containers like so:
/var/log/kubernetes/%namespace%/%deployment%/%podname%.log

Does anyone have experience with logging to file?

Kind regards,

Michael