TL;DR
-
std-out -> fluentd:在启动程序时将程序输出重定向到文件。在 linux 上,使用 logrotate,你会喜欢的。
-
Windows:使用fluent-bit。
-
应用端配置:使用单一(或可预测的)日志位置,以及
fluentd/fluent-bit 'in_tail' 插件。
日志一般:
如果必须将标准输出写入文件pipe it's output at program startup,建议始终将应用程序输出写入文件。为了使 fluentd 配置更加灵活,请将它们通过管道传输到单独的文件中(就像 'Apache' 所做的那样):
My_program.exe Do some crazy stuf > my_out_file.txt 2> my_error_file.txt
这会打开 fluentd 从这个/这些文件中读取的选项。
窗户:
对于 Windows 系统,使用fluent-bit,它可能会解决聚合 Windows 操作系统程序日志的问题。最近刚刚实现了对 Windows 的支持。
fluent-bit 支持:
- 'tail' 插件,它在一个sqllite3数据库,处理不可处理的数据,分配给某个key(默认为'log')
- 适用于 Windows 机器,但请注意它不能 buffer to disk,因此请确保及时重新建立或修复丢失的连接或其他输出问题,以免遇到 OOM 问题。李>
应用程序。侧面配置:
tail 插件可以监控文件夹,这使得将配置保留在程序一侧几乎成为可能。只需确保将不同应用程序的日志写入可预测的目录即可。
Fluent 位设置/配置:
对于 Linux,只需使用 fluentd(需要每秒发送unless > 100000 条消息,这就是 fluent-bit 成为您唯一选择的地方)。
对于 Windows,安装 Fluent-bit,并使其作为守护进程运行(几乎很有趣 sollution)。
有2种执行方式:
- 直接通过命令行提供配置
- 使用配置文件(zip 中包含的示例),并使用
-c 标志引用它。
直接从命令行
可以在此处找到一些示例执行(不使用使用配置文件的选项):
PS .\bin\fluent-bit.exe -i winlog -p "channels=Setup,Windows PowerShell" -p "db=./test.db" -o stdout -m '*'
-i 声明输入法。目前,只实现了几个插件,请参阅下面的手册页。
PS fluent-bit.exe --help
Available Options
-b --storage_path=PATH specify a storage buffering path
-c --config=FILE specify an optional configuration file
-f, --flush=SECONDS flush timeout in seconds (default: 5)
-F --filter=FILTER set a filter
-i, --input=INPUT set an input
-m, --match=MATCH set plugin match, same as '-p match=abc'
-o, --output=OUTPUT set an output
-p, --prop="A=B" set plugin configuration property
-R, --parser=FILE specify a parser configuration file
-e, --plugin=FILE load an external plugin (shared lib)
-l, --log_file=FILE write log info to a file
-t, --tag=TAG set plugin tag, same as '-p tag=abc'
-T, --sp-task=SQL define a stream processor task
-v, --verbose increase logging verbosity (default: info)
-s, --coro_stack_size Set coroutines stack size in bytes (default: 98302)
-q, --quiet quiet mode
-S, --sosreport support report for Enterprise customers
-V, --version show version number
-h, --help print this help
Inputs
tail Tail files
dummy Generate dummy data
statsd StatsD input plugin
winlog Windows Event Log
tcp TCP
forward Fluentd in-forward
random Random
Outputs
counter Records counter
datadog Send events to DataDog HTTP Event Collector
es Elasticsearch
file Generate log file
forward Forward (Fluentd protocol)
http HTTP Output
influxdb InfluxDB Time Series
null Throws away events
slack Send events to a Slack channel
splunk Send events to Splunk HTTP Event Collector
stackdriver Send events to Google Stackdriver Logging
stdout Prints events to STDOUT
tcp TCP Output
flowcounter FlowCounter
Filters
aws Add AWS Metadata
expect Validate expected keys and values
record_modifier modify record
rewrite_tag Rewrite records tags
throttle Throttle messages using sliding window algorithm
grep grep events by specified field values
kubernetes Filter to append Kubernetes metadata
parser Parse events
nest nest events by specified field values
modify modify records by applying rules
lua Lua Scripting Filter
stdout Filter events to STDOUT