「Fluentd」:修訂間差異
跳至導覽
跳至搜尋
(未顯示同一使用者於中間所作的 5 次修訂) | |||
第10行: | 第10行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
curl -L https://packages.treasuredata.com/GPG-KEY- | curl -L https://packages.treasuredata.com/GPG-KEY-td-agent | gpg --dearmor | sudo tee /usr/share/keyrings/fluent-lts-archive-keyring.gpg > /dev/null; echo "Types: deb\nURIs: https://packages.treasuredata.com/lts/5/ubuntu/$(lsb_release -cs)/\nSuites: jammy\nComponents: contrib\nSigned-By: /usr/share/keyrings/fluent-lts-archive-keyring.gpg" | sudo tee /etc/apt/sources.list.d/fluent-lts.sources; sudo apt update; sudo apt install -y td-agent | ||
</syntaxhighlight> | </syntaxhighlight> | ||
第28行: | 第28行: | ||
auth_basic_user_file /srv/fluent.example.com/.htpasswd; | auth_basic_user_file /srv/fluent.example.com/.htpasswd; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_pass http://127.0.0.1: | proxy_pass http://127.0.0.1:8888/; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
接著在<code>/etc/ | 接著在<code>/etc/flient/fluent.conf</code>內的設定比較簡單: | ||
<syntaxhighlight lang="apache"> | <syntaxhighlight lang="apache"> | ||
第38行: | 第38行: | ||
<source> | <source> | ||
@type http | @type http | ||
port | port 8888 | ||
bind 127.0.0.1 | bind 127.0.0.1 | ||
add_remote_addr true | add_remote_addr true | ||
</source> | </source> | ||
<match | <match *> | ||
@type copy | @type copy | ||
<store> | <store> | ||
第62行: | 第62行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
另外建立<code>/var/log/fluent</code>,要設為<code> | 另外建立<code>/var/log/fluent</code>,要設為<code>_fluentd</code>這個使用者: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo mkdir /var/log/fluent; sudo chown | sudo mkdir /var/log/fluent; sudo chown _flientd:_fluentd /var/log/fluent | ||
</syntaxhighlight> | </syntaxhighlight> | ||
於 2024年7月30日 (二) 01:23 的最新修訂
Fluent是一套Log處理軟體。
簡介
我是拿來跑server端(接收端)而非client端(發送端)。
安裝
在Ubuntu上安裝:
curl -L https://packages.treasuredata.com/GPG-KEY-td-agent | gpg --dearmor | sudo tee /usr/share/keyrings/fluent-lts-archive-keyring.gpg > /dev/null; echo "Types: deb\nURIs: https://packages.treasuredata.com/lts/5/ubuntu/$(lsb_release -cs)/\nSuites: jammy\nComponents: contrib\nSigned-By: /usr/share/keyrings/fluent-lts-archive-keyring.gpg" | sudo tee /etc/apt/sources.list.d/fluent-lts.sources; sudo apt update; sudo apt install -y td-agent
另外安裝fluent-plugin-slack:
sudo fluent-gem install fluent-plugin-slack
設定
我是透過nginx包裝成HTTPS服務,另外進行帳號密碼的管制(HTTP Authentication),主要的重點是:
location / {
auth_basic "Restricted Content";
auth_basic_user_file /srv/fluent.example.com/.htpasswd;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8888/;
}
接著在/etc/flient/fluent.conf
內的設定比較簡單:
#
<source>
@type http
port 8888
bind 127.0.0.1
add_remote_addr true
</source>
<match *>
@type copy
<store>
@type file
path /var/log/fluent/
</store>
<store>
@type slack
channel fluentd
flush_interval 5s
message_keys log
parse none
title_keys REMOTE_ADDR
title %s
webhook_url https://hooks.slack.com/services/...
</store>
</match>
另外建立/var/log/fluent
,要設為_fluentd
這個使用者:
sudo mkdir /var/log/fluent; sudo chown _flientd:_fluentd /var/log/fluent
相關連結
外部連結
- 官方網站 (英文)