Using NLS to log dynamic docker hosts

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
roddergreg
Posts: 59
Joined: Wed Oct 22, 2014 4:35 am

Using NLS to log dynamic docker hosts

Post by roddergreg »

Hello,

We are running containers inside a docker host. When a new docker host is created a different hostid hash is created. We are trying to build and elastic type apache environment. Depending on CPU Load an application called marathon will fire up another apache container to help with the load.

The question I have is: Is there a way to configure the rsyslog daemon on each docker to use a dyamic name when sending the logs?

So we have 1 Docker Host. In the host we are running about 4 apache containers with rsyslog running.

Inside the container we are writing apache logs to /var/log/httpd/$HOSTNAME/access. I want to ship these logs with a dynamic hostname to our NLS. Currently it appears that we would have to setup rsyslog on each container to ship them to the Log Server. This sounds like an administrative nightmare. Especially if the marathon process decides to start up another instance.

Is there any way to setup rsyslog to use dynamic names?

Thank you in advance,

Greg Cooper
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Using NLS to log dynamic docker hosts

Post by eloyd »

Greg,

I may be missing what you're asking exactly, but rsyslog does not send information with a hostname. It is receiving side that identifies the IP of the sender and optionally assigns a hostname. Since rsyslog is a file-level monitoring service, then yes, if you want to send /var/log/httpd/<dynamic thing>/access to NLS, you would have to set up rsyslog to send each <dynamic thing> log file, as you say.

rsyslogd does support wildcards for filenames (http://www.rsyslog.com/doc/master/confi ... mfile.html) but not for directories. Which, for me, means if you can change /var/log/httpd/$HOSTNAME/access to /var/log/httpd/$HOSTNAME.access, then you could monitor /var/log/httpd/* via rsyslog and get all your container access logs via the wildcard processing.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Using NLS to log dynamic docker hosts

Post by hsmith »

Thanks, Eric!

@ roddergreg, does this answer your question?
Former Nagios Employee.
me.
prhunixadmin
Posts: 22
Joined: Tue Apr 07, 2015 1:21 pm

Re: Using NLS to log dynamic docker hosts

Post by prhunixadmin »

Yes this answers my question but we've decided to go another route.

I do have another questions that involves ENV variables.

Since we are running docker containers I'd like to include the MARATHON_APP_ID variable as part of the tag for the syslog messages being shipped to nagioslogserver.

Is there any way to pass an environment variable that rsyslog could read as part of the tag?
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Using NLS to log dynamic docker hosts

Post by eloyd »

Environment variables are not part of the tag. At least, not dynamically assigned ones. You'd have to reconfigure the rsyslog sender tag each time the variable was set/changed and restart rsyslog.

A potentially better solution is to teach NLS that data from certain hosts, sender types, or matched data (or a combination of things) belongs to a certain tag, and tag it in the input filter.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Using NLS to log dynamic docker hosts

Post by rkennedy »

Thanks @eloyd! As mentioned, your best bet is going to be tagging an additional field at the input level.

Let us know if you have any further questions.
Former Nagios Employee
Locked