Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

Jaegeun's Life Story

Fluentd 설치 및 셋팅 본문

IT/Fluentd

Fluentd 설치 및 셋팅

정이많은친구 2017. 9. 14. 10:47

* Ubuntu 16.04 LTS 기준



* 설치


1. td-agent 설치

curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent2.sh | sh



2. 데몬 실행

/etc/init.d/td-agent restart (재시작)

/etc/init.d/td-agent status (상태 확인)



3. 시작시 자동 스크립트 실행

sudo update-rc.d td-agent defaults 95 10

sudo service td-agent status


4. 테스트

curl -X POST -d 'json={"json":"message"}' http://localhost:8888/debug.test


/var/log/td-agent/td-agent.log 에 들어가보면 아까 전송한 메시지를 확인할 수 있음





* 기본 셋팅


플런트디 config file은 /etc/td-agent/td-agent.conf 에서 볼 수 있음


각 태그들에 대한 설명

1. source

2. match

3. filter

4. label

5. @include



source

source는 input source를 결정한다. 플런트디의 기본적인 input plugins은 http, forward를 포함한다.

http는 HTTP message로부터 받음

forward는 tcp packets으로부터 받음


어느 label로 갈지 설정할 수도 있음

<source>

  @label @METRICS

</source>


<label @METRICS>

 ...

</label>



match

match는 output destination을 결정한다. 

match는 pattern을 가지는데 이는 플런트디로 오는 이벤트 흐름을 제어한다.


*, ** pattern

*는 single part, **는 zero or more tage part


a.* 일 경우,  a.b는 매치하지만, a, a.b.c 는 매치하지 않음

a.**일 경우, a, a.b, a.b.c 모두 매치함


{} pattern

{a,b}일 경우, a, b를 매치함

*, ** pattern과 결합할 수 있음

a.{b,c}.** 일 경우, a.b, a.c, a.b.c, a.c.b 모두 매치할 수 있음



* match 순서는 config 파일 순서에 나타나는 대로 먼저 매치됨


만약 두 match가 순서대로 있을 때,

<match **>

...

</match>


<match test.test>

...

</match>

유저가 test.test로 로그를 전송했을 때, <match test.test>에 매치되지 않음



filter

match와 syntax가 비슷하지만, filter는 파이프라인 처리를 위해 연결될 수 있음

input --> filter1 --> filter2 --> ... --> filterN --> output



* 먼저 fluent 폴더를 만들어야 하고, 권한을 변경해야함

* chown td-agent:td-agent /var/log/fluent



label

label은 filter와 output을 그루핑할 수 있음


<label>

  <filter>

   ...

  </filter>


  <match>

   ...

  </match>

</label>



@include

@include는 중요한 config file들을 import해 수행시킬 수 있음

@include a.conf

@include config.d/*.conf

등등



<참조: https://docs.fluentd.org/v0.12/articles/config-file>

'IT > Fluentd' 카테고리의 다른 글

custom plugin install  (0) 2017.09.20
Buffer Plugin  (0) 2017.09.14
Comments