docker log driver
[get information from running containers and services]
配置:
set the value of log-driver to the name of the logging driver in the daemon.json configuration file
能不能找到不通过Docker Daemon收集日志直接将日志内容重定向到文件并自动 rotate的工具呢?答案是肯定的采用S6[2]基底镜像。
S6-log 将 CMD 的标准输出重定向到/…/default/current,而不是发送到 Docker Daemon,这样就避免了 Docker Daemon 收集日志的性能瓶颈
k8s log
节点的容器日志处理方式
容器运行时对写入到容器化应用程序的 stdout 和 stderr 流的所有输出进行处理和转发。 不同的容器运行时以不同的方式实现这一点;不过它们与 kubelet 的集成都被标准化为 CRI 日志格式。
kubelet 通过 Kubernetes API 的特殊功能将日志提供给客户端访问。 访问这个日志的常用方法是运行 kubectl logs。
s6
s6 is a collection of utilities revolving around process supervision and management, logging, and system initialization.
At its core, s6 is a process supervision suite, like its ancestor daemontools and its close cousin runit.
A process supervision system organizes the process hierarchy in a radically different way.
- A process supervision system starts an independent hierarchy of processes at boot time, called a supervision tree. This supervision tree never dies: when one of its components dies, it is restarted automatically. To ensure availability of the supervision tree at all times, it should be rooted in process 1, which cannot die.
- A daemon is never started, either manually or in a script, as a scion of the script that starts it. Instead, to start a daemon, you configure a specific directory which contains all the information about your daemon; then you send a command to the supervision tree. The supervision tree will start the daemon as a leaf. In a process supervision system, daemons are always spawned by the supervision tree, and never by an admin's shell.
- The parent of your daemon is a supervisor. Since your daemon is its direct child, the supervisor always knows the correct PID of your daemon.
- The supervisor watches your daemon and can restart it when it dies, automatically.
- The supervision tree always has the same environment, so starting conditions are reproducible. Your daemon will always be started with the same environment, whether it is at boot time via init scripts or for the 100th automatic - or manual - restart.
- To send signals to your daemon, you send a command to its supervisor, which will then send a signal to the daemon on your behalf. Your daemon is identified by the directory containing its information, which is stable, instead of by its PID, which is not stable; the supervisor maintains the correct association without a race condition or the other problems of .pid files.
what is syslog
when someone says syslog, they might mean:
- A local file on a system like /var/log/messages on an Ubuntu virtual machine
- A way to send log messages over the network such as sending logs from endpoints to a syslog server listening for traffic on UDP port 514
- One of several ways to format log messages, including the legacy BSD syslog format that is still popular in the wild
fluentd
Fluentd is an open source data collector, which lets you unify the data collection and consumption for a better use and understanding of data.
Unified Logging with JSON
Pluggable Architecture
Minimum Resources Required
Fluentd is written in a combination of C language and Ruby, and requires very little system resource. The vanilla instance runs on 30-40MB of memory and can process 13,000 events/second/core.
Built-in Reliability
Fluentd supports memory- and file-based buffering to prevent inter-node data loss.