fluentd
#infra
๋ก๊ทธ ์์ง๊ธฐ (collector)
๋ฐ์ดํฐ ์ ์ค์ ๋ง๊ธฐ ์ํด ๋ฉ๋ชจ๋ฆฌ, ํ์ผ ๊ธฐ๋ฐ์ Buffer ์์คํ ์ ๊ฐ์ง๊ณ ์์.
Failover์ ์ํ HA(high availability) ๊ตฌ์ฑ๋ ๊ฐ๋ฅ.
HA? ํด๋ฌ์คํฐ๋ง, ์ด์คํ๋ฑ์ ๋ฐฉ์. ์ฆ ํ๋์
fluentd
์์คํ ์ด ์์น ์์ ์ด์ ๋ก ์ข ๋ฃ๋์์ ๊ฒฝ์ฐ, ๋ค๋ฅธfluentd
์์คํ ์ด ์์ด์ ๋ก๊ทธ ๋ฐ์ดํฐ์ ์ ์ค์ ๋ง์์ฃผ๋ ๊ฒ.
Inputs or listeners Fluentd will have and set up common matching rules to route the Event data to a specific Output.
input data๋ ํน์ ํ ๋ฃฐ์ ๋งค์นญ๋์ด์ output์ผ๋ก ์ ํ๋๋ค.
์ ์ฒด์ ์ธ ๋์์ input -> (Filter) -> Buffer -> Output
์๋ฅผ ๋ค๋ฉด
HTTP Request
๋ ์๋์ ๊ฐ์ ๋ฐ์ดํฐ๋ก ์ ํ.
ํน์ ํ ๋ฃฐ (Matching rule)
The Match sets a rule where each Incoming event that arrives with a Tag equals to test.cycle, will match and use the Output plugin type called stdout
test.cycyle
์ด๋ผ๋ Tag์ ํจ๊ป ๋ค์ด์ค๋ ์ด๋ฒคํธ๋stdout
์ด๋ผ๊ณ ๋ถ๋ฆฌ๋ output plugin type์ ์ฌ์ฉํ ๊ฒ์ด๋ผ๋ ๋ฃฐ์.tag, event๋?
Event Srtucture
3๊ฐ์ ์์๋ก ๊ตฌ์ฑ๋จ.
tag : ๋ฉ์ธ์ง ๋ผ์ฐํ ์ ์ฌ์ฉ๋๋ฉฐ, ์ด๋ฒคํธ๊ฐ ์ด๋์์ ๋ค์ด์ค๋ ์ง ํ์ธํ๋ ์ฉ๋.
time : ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ ์๊ฐ (nanosecond)
record : JSON Obect ํ์์ ์ค์ ๋ก๊ทธ (์ ์กํด์ผํ )
Processing Events
input data๋ฐ๋ผ, ๊ฐ๊ฐ ๋ค๋ฅธ ์ด๋ฏธ ์ ์๋ ๋ฃฐ์ ์ ์ฉ ์ํฌ ์ ์์.
์ฆ ๋ด๋ถ์ ์ผ๋ก ์ด๋ฒคํธ๊ฐ ์ ์ก๋๊ธฐ ์ ์, ์ด๋ค ์ฒด์ธ์ผ๋ก ์ฐ๊ฒฐ๋ ๋ฃฐ์ ์ ์ฉ์ํจ๋ค๊ณ ๋ณด๋ฉด ๋ ๋ฏ.
Filter
A Filter behaves like a rule to pass or reject an event
ํต๊ณผ์ํค๊ฑฐ๋, ๊ฑฐ๋ถํ๋ ๋ฃฐ์ธ๋ฏ.
match ์ ์ ์ ์๋์์
grep์ก์์, key ๊ฐ action์ธ ๋ฐ์ดํฐ์ ๊ฐ์ด
logout
ํจํด์ด๋ผ๋ฉด, ์ด ์ด๋ฒคํธ๋ ๊ฑฐ๋ถ๋จ.์ฆ
์ฒซ๋ฒ์งธ ์ด๋ฒคํธ๋ filter๋ฅผ ํต๊ณผํ๊ณ , ๋๋ฒ์งธ ์ด๋ฒคํธ๋ ํํฐ๋ฅผ ํต๊ณผํ์ง ๋ชปํจ.
Label
aims to solve the configuration file complexity and allows to define new Routing sections that do not follow the top-to-bottom order, instead they act like linked references
configuratoin ํ์ผ์ ๋ณต์ก์ฑ์ ํด๊ฒฐํ๊ธฐ ์ํด ๋์์.
์๋ก์ด Routing section์ ํ์ฉํด์ฃผ๋ ๊ฒ.
ํด๋น label์ ์ ์ํ๋ฉด, filter ๋ณด๋ค ๋จผ์ ์ฐพ์๊ฐ๊ฒ ๋๋๋ฏ.(์ด์ ํํฐ๋ ์ ์งํ๊ณ , ์๋ก์ด ํํฐ๋ฅผ ์ ์ฉํ๊ณ ์ถ์ ๋ ์ฌ์ฉ๋๋ ๋ฏ ๋ฒ์ ธ๋ ๋๋)
Buffers
In this example, we use stdout, the non-buffered output you use outputs in buffered mode e.g. forward, mongodb, s3 and etc.
์์์ ์ฌ์ฉ๋ ์์๋ non-bufftered output์ธ stdout.
๊ทธ๋ ์ง๋ง forward, mongodb, s3์ ๊ฐ์ ๊ฐ์
@type
๊ณผ ์ฌ์ฉํ๋ฉด, buffered mode๋ฅผ ์ฌ์ฉํ ์ ์์.
first stores the received events into buffers and then writes out buffers to a destination after meeting flush conditions
์ฒซ๋ฒ์งธ store๋ ์ด๋ฒคํธ๋ฅผ ๋ฐ๊ณ , ๊ทธ๋ฆฌ๊ณ flush ์กฐ๊ฑด์ ๋ง์กฑํ๋ฉด, ๋ชฉ์ ์ง ๋ฒํผ์ ์ธ ์ ์๋ ๋ฏ. (์ฒซ๋ฒ์งธ ์ด๋ฒคํธ ์คํ ์ด ๋ฒํผ์ ์ ์ฅ๋ ์ ๋ณด๋ฅผ ๋ณด๋ธ๋ค๋ ์๋ฏธ์ธ๋ฏ)
Input plugins
tail
๋ก๊ทธ ํ์ผ์
tail
๋ช ๋ น์ด๋ฅผ ํตํด์ ์ฝ์ด์ค๋ ๊ฒ์ ๋งํจ.๋ก๊ทธ ํ์ผ์ด ๋ณ๊ฒฝ๋๋ฉด (rotated), ์๋ก์ด ํ์ผ์ ์ฝ๊ธฐ ์์ํจ.
pos_file
์ ์ฌ์ฉํ ๊ฒฝ์ฐ, fluentd๊ฐ ์ฌ ์คํ๋์์ ๋, ์ฝ์ ํ์ผ์ ๋ง์ง๋ง ์์น ๋ถํฐ ๋ค์ ์์ํ๊ฒ ๋์์ค.position file
forward
๋ณดํต ๋ค๋ฅธ fluentd ๋ ธ๋๋ก ๋ถํฐ ๋ฐ์ดํฐ๋ฅผ ์ ๋ฌ๋ฐ๊ธฐ ์ํด ์ฌ์ฉํจ.
์ ๋ฌ๋ฐ๋ ๋ฐ์ดํฐ๋ JSON ์ด๋ Messagepack ํ์์ผ๋ก ๊ตฌ์ฑ๋์ด์์.
Output plugins
forward
The out_forward Buffered Output plugin forwards events to other fluentd nodes. For replication, please use out_copy plugin.
์ด๋ฒคํธ๊ฐ ๋ค๋ฅธ fluentd node๋ก forward ๋๋ ๊ฒ์ ์๋ฏธ
๋ณต์ ๋ฐฉ์์
out_copy
ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํด๋ผstandby
optiondefault : false
ํด๋น ๋ ธ๋๋ standby ํ์ ์ด๋ผ ๋ช ์ํด์ค.
๋ง์ฝ์ active node๊ฐ ๋ฉ์ถ๋ฉด, standby node๊ฐ ํด๋น ์ญํ ์ ๋์ ํจ.
์ฆ ๊ธฐ๋ณธ์ ์ผ๋ก
forward
๋ฐฉ์์์ standby node๋ก ์ค์ ๋ ๋ ธ๋๋ ์ด์ฉ๋์ง ์์.
s3
real world use case
์ค์ production ํ๊ฒฝ์ ์ ์ฉํ๋ ค ํ ๋, ์ฐธ๊ณ ํด๋ณด๋ฉด ์ข์๋ฏ.
์ฐธ๊ณ
https://jonnung.dev/system/2018/04/06/fluentd-log-collector-part1/
https://docs.fluentd.org/
Last updated
Was this helpful?