td-agent rest api/avro 방식으로 syslog 전달
2025. 4. 7. 23:58ㆍk8s/EFK
# 디버깅 추가
<system>
log_level debug
</system>
# syslog 정보 가져오기
<source>
@type tail
path /var/log/syslog
pos_file /var/log/td-agent/syslog.pos
tag syslog.all
read_from_head true
<parse>
@type syslog
</parse>
</source>
# AVRO 방식으로 데이터 전송
# records는 필요한 컬럼 하나씩 상세히 기술해줘야 함
<filter syslog.all>
@type record_transformer
enable_ruby true
<record>
value_schema '{\"type\":\"record\",\"name\":\"SyslogRecord\",\"fields\":[{\"name\":\"host\",\"type\":\"string\"},{\"name\":\"ident\",\"type\":\"string\"},{\"name\":\"pid\",\"type\":\"string\"},{\"name\":\"message\",\"type\":\"string\"}]}'
records [{"value":{"host":"${record['host']}","ident":"${record['ident']}","pid":"${record['pid']}","message":"${record['message']}"}}]
</record>
remove_keys host,ident,pid,message
</filter>
# 디버깅을 위해서 전송할 내용 출력
# @type http보다 앞에 있어서 출력이 됨
<match syslog.all>
@type stdout
</match>
# fluent-plugin-out-http/versions/1.3.4 사용
<match syslog.all>
@type http
endpoint_url http://192.168.0.54:8081/topics/ubuntu_syslog
http_method post
serializer json
<buffer>
flush_interval 5s
</buffer>
</match>