Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions apps/fluentbit/Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@

## 日志收集

### 示例:收集wordpress的日志
1. 在wordpress容器编排文件中修改日志引擎为fluentd
```
logging:
driver: fluentd
options:
fluentd-address: 47.83.26.60:9001 # url+暴露的端口 (由于Portainer Stack模式只能通过overlay网络相互解析服务名,默认的websoft9是桥接网络,所以不能用服务名加端口查找)
tag: "wordpress.app" # 标签,用于区分不同的日志
```
2. 编辑fluent-bit.conf
### 示例:监控收集cpu指标并存储到指定文件
1. 编辑fluent-bit.conf
```
[SERVICE]
Flush 1
Log_Level info
Flush 1
Log_Level info

[INPUT]
Name forward
Port 24224
Listen 0.0.0.0
Name cpu
Tag my_cpu # 设置标签
Interval_Sec 1 # 1秒间隔
Threaded true

[OUTPUT]
Name file
Match wordpress.app # 匹配标签
Path /var/log/fluentbit # 日志输出路径(已在编排文件中将该目录映射到外部)
File wordpress.log # 日志文件名(如果不加这一项,则默认按照标签名创建文件)
Mkdir On # 如果目录不存在,则创建
Format plain
Name file
Match my_cpu # 匹配标签
Path /var/log/fluentbit # 日志输出路径(已在编排文件中将该目录映射到外部)
File cpu.log # 日志文件名(如果不加这一项,则默认按照标签名创建文件)
Mkdir On # 如果目录不存在,则创建

[OUTPUT]
Name stdout
Expand Down
2 changes: 1 addition & 1 deletion apps/fluentbit/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ volumes:
networks:
default:
name: $W9_NETWORK
external: true
external: true
23 changes: 12 additions & 11 deletions apps/fluentbit/src/fluent-bit.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[SERVICE]
Flush 1
Log_Level info
Flush 1
Daemon off
Log_Level info

[INPUT]
Name forward
Port 24224
Listen 0.0.0.0
Name cpu
Tag my_cpu
Interval_Sec 1
Threaded true

[OUTPUT]
Name file
Match wordpress.app
Path /var/log/fluentbit
File wordpress.log
Mkdir On
Format plain
Name file
Match my_cpu
Path /var/log/fluentbit
File cpu.log
Mkdir On

[OUTPUT]
Name stdout
Expand Down
1 change: 1 addition & 0 deletions apps/fluentbit/variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{
"dist": "community",
"version": [
"4.2",
"latest"
]
}
Expand Down