Managing Application Logs

Applications running on tsuru should send all their log messages to stdout andstderr. This will allow docker to capture these logs and forward them accordingto instructions configured by tsuru.

There are basically two ways to setup application logs in tsuru. Through bscontainer and directly to an external log service. The sections below will talkabout the configuration options and advantages of each setup.

bs

bs (or big sibling) is a container started automatically by tsuru on everydocker node created or registered in tsuru. It’s responsible for reportinginformation on application containers, this information include metrics, unitstatus and can also include container logs.

On a default tsuru installation all container started on docker will beconfigured to send logs to the bs container using the syslog protocol. The bscontainer will then send the logs to the tsuru api server and to any number ofconfigured external syslog servers. Similar to the diagram below:

  1. Docker Node
  2. +---------------------------------------------------------+ +---------------------+
  3. | syslog | | |
  4. | +----------------->| ext syslog server 1 |
  5. | +-----------------+ syslog |(optional)| | |
  6. | | app container |+----------+ | | +---------------------+
  7. | +-----------------+ | + |
  8. | | +--------------+ | +---------------------+
  9. | +----->| |syslog | |
  10. | | bs container |+-------->| ext syslog server 2 |
  11. | +----->| |(optional)| |
  12. | | +--------------+ | +---------------------+
  13. | +-----------------+ syslog | + |
  14. | | app container |+----------+ | |
  15. | +-----------------+ | |
  16. | | |
  17. | | |
  18. | | |
  19. +----------------------------------------------|----------+
  20. |
  21. |
  22. +-------------------+ |
  23. | | websocket (optional) |
  24. | tsuru api server |<-------------------------+
  25. | |
  26. +-------------------+

For informations about how to configure bs to forward logs and also some tunningoptions, please refer to the bs documentation

The advantage of having the bs container as an intermediary is that it knows howto talk to the tsuru api server. Sending logs to the tsuru api server enablesthe tsuru app-log command which can be used to quickly troubleshoot problemswith the application without the need of a third-party tool to read the logs.

However, tsuru api server is NOT a permanent log storage, only the latest 5000log lines from each application are stored. If a permanent storage is requiredan external syslog server must be configured.

Direct

tsuru can be configured to completely bypass bs when sending logs. This can bedone using the tsuru docker-log-update command. See the commandreference documentationfor more details.

When a log-driver different from bs is chosen, the logs will be similarto the diagram below:

  1. Docker Node
  2. +-----------------------+
  3. | |
  4. | +-----------------+ |
  5. | | app container |-+|
  6. | +-----------------+ |chosen driver +---------------------+
  7. | +----------------->| |
  8. | | | external log server |
  9. | +----------------->| |
  10. | +-----------------+ |chosen driver +---------------------+
  11. | | app container |-+|
  12. | +-----------------+ |
  13. | |
  14. +-----------------------+

The downside of using a direct logs is that the tsuru api server will NOTreceive any log messages anymore. As a consequence the command tsuru app-logwill be disabled and users will have to refer to the chosen log driver to readlog messages.

原文: https://docs.tsuru.io/1.6/managing/logs.html