Infrastructure/Fluentd

[Fluentd] 4. Input plugin

상쾌한기분 2021. 5. 11. 14:47
728x90
반응형

Input Plugin

https://docs.fluentd.org/input

tail

tail 은 꼬리로, 텍스트 파일의 꼬리를 쫓는다. 리눅스 커맨드 tail 과 비슷하다.

아래는 Nginx access log tail 샘플

<source>
  @type tail
  @label @NGINX_LOG
  @id NGINX_ACCESS_LOG

  tag nginx.access
  path /var/log/nginx/access.log
  pos_file /var/log/td-agent/nginx-access.log.pos

  <parse>
    @type nginx
  </parse>
  @log_level debug
</source>

forward

forward 는 포트 열고 통신 대기한다고 생각하면 됨
fluentd -> fluentd
fluentd -> prometheus

<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>

http

http 는 HTTP request 로 데이터 전송 가능하게 해줌

<source>
  @type http
  port 9880
  bind 0.0.0.0
  body_size_limit 32m
  keepalive_timeout 10s
</source>
# Post a record with the tag "app.log"
$ curl -X POST -d 'json={"foo":"bar"}' http://localhost:9880/app.log

$ curl -X POST -d 'json={"foo":"bar"}' \
  http://localhost:9880/test.tag?time=1518756037.3137116

var form = new FormData();
form.set('json', JSON.stringify({"foo": "bar"}));

var req = new XMLHttpRequest();
req.open('POST', 'http://localhost:9880/debug.log');
req.send(form);
728x90
반응형