هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
Fluent Bit (CNCF, part of Fluentd) runs on each host or as a DaemonSet in Kubernetes. A pipeline has inputs (tail, systemd, kubernetes events), filters (kubernetes metadata, grep, modify, lua, masking) and outputs (loki, es, azure_logs_ingestion, s3, forward, stdout). It uses little memory (a few MB), so it is the common choice for log shipping.
Config is classic .conf sections or YAML (fluent-bit.yaml).
طريقة الكتابة
fluent-bit -c CONFIG
fluent-bit -i INPUT -o OUTPUT [-p key=value]الأجزاء الرئيسية
Pipeline parts
- [INPUT]
tail - Read log files (with position database).
- [INPUT]
systemd - Read the journal.
- [FILTER]
kubernetes - Add pod, namespace and labels.
- [FILTER]
grep - Keep or drop records by regex.
- [FILTER]
modify/record_modifier - Add, rename, remove fields.
- [OUTPUT]
loki - Send to Loki.
- [OUTPUT]
es - Send to Elasticsearch/OpenSearch.
- [OUTPUT]
azure_logs_ingestion - Send to Azure Monitor (DCR).
- [OUTPUT]
stdout - Print (debugging).
الخيارات 6
الأكثر استخدامًا
Command-line flags
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 10
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Test quickly on the terminal
fluent-bit -i cpu -o stdout -f 1 fluent-bit -i systemd -p systemd_filter=_SYSTEMD_UNIT=sshd.service -o stdout2Ship nginx logs to Loki
cat /etc/fluent-bit/fluent-bit.conf [SERVICE] Flush 5 HTTP_Server On [INPUT] Name tail Path /var/log/nginx/access.log Tag nginx.access DB /var/lib/fluent-bit/nginx.db [OUTPUT] Name loki Match nginx.* Host loki.lab.local Port 3100 Labels job=nginx, host=${HOSTNAME}3Check the config
fluent-bit -c /etc/fluent-bit/fluent-bit.conf --dry-run systemctl restart fluent-bit4Read the journal and drop debug lines
cat /etc/fluent-bit/journal.conf [INPUT] Name systemd Tag host.* Read_From_Tail On [FILTER] Name grep Match host.* Exclude PRIORITY ^7$5Hide secrets before sending
cat /etc/fluent-bit/mask.conf [FILTER] Name modify Match * Remove password Remove authorization6Install on Kubernetes with Helm
7Add Kubernetes metadata
cat fluent-bit-values.yaml config: filters: | [FILTER] Name kubernetes Match kube.* Merge_Log On Keep_Log Off8Watch its own health
9Read its logs
journalctl -u fluent-bit -f10Send to Azure Monitor Logs
cat /etc/fluent-bit/azure.conf [OUTPUT] Name azure_logs_ingestion Match * client_id ${AZ_CLIENT_ID} client_secret ${AZ_CLIENT_SECRET} tenant_id ${AZ_TENANT_ID} dce_url https://dce-lab-weu.westeurope-1.ingest.monitor.azure.com dcr_id dcr-00000000000000000000000000000000 table_name Syslog_CL
لا يوجد شيء يطابق هذا الفلتر.
انتبه
- Logs often contain tokens, passwords and personal data: filter or mask them before they leave the host.
- Without a
DBfile fortail, a restart re-sends or loses lines. - Use TLS (
tls On) for outputs that leave the host.
الملفات
/etc/fluent-bit/fluent-bit.conf- Main config.
/etc/fluent-bit/parsers.conf- Parsers (json, regex, docker, cri).
نصائح للحفظ
- Use
Mem_Buf_Limitandstorage.type filesystemso a slow backend does not eat all memory.
رموز الخروج
0 | Success. |
1 | Error (bad config). |