背景
去年11月份研究了一下开源的datadog agent代码(7.32.1), 整理了一篇文档。
1 日志数据流转
- tailer首先从log文件读取,将读取的内容源源不断地发送到 decoder的 input channel中
- decoder 从自身的input channel读取数据 ,判断数据是否需要截断,将数据写入line parser的 input channel
- line parser从自身的input channel读取数据,解析内容、status、时间戳等,写入line handler的 input channel
- line handler从自身的input channel 读取数据,去除空格,发送到自身的output channel
- tailer forwardMessage 从decoder的output channel(与line handler共享)读取数据,添加tag后, 发送给pipeline的 input channel
- processor 从自身的input channel(pipe line的input channel)读取数据,encode后(比如encode为json/pb格式),发送到sender的input channel
- sender 从input channel读取数据,最后又将message写入pipeline的output channle
- sender将message的content发送给datadog 后台,发送时默认不压缩传输,http支持gzip压缩传输,tcp不支持压缩。
- pipeline的output channel初始传入的是auditor的 input channel。 auditor从input channel 读取数据,写入内存 ,定时器从buffer刷入磁盘,另外一个定时器定期清理内存过期数据

