Da ich es nicht schön fand, die Container nach den Json-Logs zu durchstöbern und weil ich die Logs per logrotate archivieren möchte, habe ich eine Lösung entwickelt, welche die Logs aus den Containern per rsyslog an meinen Host schickt.
Diese Anleitung erhebt keinen Anspruch auf Vollständigkeit, aber vielleicht will der ein oder andere es nachvollziehen und vielleicht geht einiges davon – konfigurierbar – in die offizielle Version/Doku ein. Es könnte bessere Lösungen geben, aber mit meinem kleinen Know How hat es geklappt. Beispiel mit meiner lokalen IP 192.168.10.1
Aktivieren des Empfangs von Syslogs auf dem lokalen Host in der Datei /etc/rsyslog.conf (Einträge aktivieren bzw. ändern). module(load="imudp") # needs to be done just once input(type="imudp" port="514" address="192.168.10.1")
Umstellen Docker auf den log-Driver syslog, statt json in der Datei /etc/docker/daemon.json:
{
„log-driver“: „syslog“,
„log-opts“: {
„syslog-address“: „udp://192.168.10.1:514“
}
}
Restart rsyslog.service, docker und Neustart von OTOBO per compser.
BINGO. Die Datei /var/log/messages ist nun voll von den Logs aus den Containern.
Ich will weitergehen, und hier kommt nun der OTOBO-spezifische Teil. Ich wollte für jeden OTOBO-Container eine eigene Log-Datei. Erweiterungen der Dateien /opt/otobo-docker/docker-compose/otobo-base.yml und /opt/otobo-docker/docker-compose/otobo-nginx-custom-config.yml. Hier habe ich bei jedem Service einen Logging-Tag eingefügt.
Zwei Beispiele:
Unter dem Service db den Eintrag logging: options: tag: "otobo_db_1"
und unter dem Servie web den Eintrag logging: options: tag: "otobo_web_1"
Neustart von OTOBO:
BINGO. In /var/log/messages kommen nun die Tags an.
Diese Tags leiten wir nun um, damit für jeden Container ein eigenes Logfile in /var/log/otobo erzeugt wird.
Datei /etc/rsyslog.conf: :syslogtag, startswith, "otobo_db_1" /var/log/otobo/otobo_db_1 :syslogtag, startswith, "otobo_web_1" /var/log/otobo/otobo_web_1 :syslogtag, startswith, "otobo_daemon_1" /var/log/otobo/otobo_daemon_1 :syslogtag, startswith, "otobo_elastic_1" /var/log/otobo/otobo_elastic_1 :syslogtag, startswith, "otobo_redis_1" /var/log/otobo/otobo_redis_1 :syslogtag, startswith, "otobo_nginx_1" /var/log/otobo/otobo_nginx_1
Restart von rsyslog.service und siehe da: ls -alt /var/log/otobo -rw-------. 1 root root 14809 Feb 28 01:38 otobo_daemon_1 -rw-------. 1 root root 3976 Feb 28 01:36 otobo_redis_1
Die Anleitung wie man die Docker Logs nach rsyslog umleitet sollte irgendwo als Howto in das Installations-Handbuch. Ich vermute aber, dass das ein bisschen dauern wird.
Auf Seiten von OTOBO gibt es auch noch ein paar Hausaufgaben. Aktuell landet das reguläre OTOBO Log in der Datei /opt/otobo/var/log/otobo.log. Sinnvoller fände ich die Ausgabe aus STDOUT so dass das reguläre Docker-Logging greifen kann. Was da das Beste Vorgehen ist kann ich aber nicht beurteilen. Meine Docker-Kenntnisse sind alle erst kürzlich angelesen.
Our website uses cookies. Cookies are tiny text files which are saved in your web browser or by your web browser on your device when you access websites. They contain a characteristic character sequence allowing to clearly identify your browser upon your next visit to the website.
You can prevent the setting of cookies at any time by making the appropriate setting in your internet browser. Cookies that have already been set can be deleted manually or automatically at any time. This is possible in all common internet browsers. If the setting of cookies is deactivated in the browser, not all functions of the website may be fully usable.
We deliberately use very little cookies.
Detailed information can be found in section 4 of our Privacy Policy.
Necessary cookies
Essential Cookies are necessary to deliver this website and some of its features correctly.
For this reason, we do not provide any opportunity here to disable them.
Notwithstanding this, you can deactivate all Cookies in your Browser Settings at any time. Please be aware, however, that this might have an impact on the functionality of this website.
More information about the cookies to be set and how long they will be stored can be found in section 4 of our Privacy Poliy: Privacy Policy.
Google Analytics' Cookies
When you visit this website, Google Analytics sets cookies on your system. This will help us analyse how you use our website ans tailor it to the needs of our visitors. Your IP address will be automatically anonymised (IP anonymisation and deactivation of your User ID). Therefore, we cannot trace which data a certain user is accessing. The data are not saved together with any other personal user data.
You can deactivate tracking in your browser if you do not want us to be able to track your visit on our website.
Privacy Policy
Detailed information on the usage of cookies as well as our Privacy Policy can be found here: