fluentd의 filter/record안에서는 예약어가 존재한다.
https://docs.fluentd.org/v0.12/articles/filter_record_transformer
<filter foo.bar>
@type record_transformer
<record>
hostname "#{Socket.gethostname}"
tag ${tag}
</record>
</filter>
요청이 다음과 같이 들어오면..
{"message":"hello world!"}
hostname과 tag가 추가된다.
{"message":"hello world!", "hostname":"db001.internal.example.com", "tag":"foo.bar"}
중간에 Parameter 내용을 보면..
record 디렉티브 하위에 tag_xxx, tag, time, hostname을 사용할 수 있다고 한다.
예를 들어 time을 통해 발생 시간이 넘어온다.
Parameters
<record> directive
Parameters inside <record>
directives are considered to be new key-value pairs:
<record>
NEW_FIELD NEW_VALUE
</record>
For NEW_FIELD and NEW_VALUE, a special syntax ${}
allows the user to generate a new field dynamically. Inside the curly braces, the following variables are available:
- The incoming event’s existing values can be referred by their field names. So, if the record is
{"total":100, "count":10}
, then record["total"]=100
and record["count"]=10
. tag_parts[N]
refers to the Nth part of the tag. It works like the usual zero-based array accessor.tag_prefix[N]
refers to the first N parts of the tag. It works like the usual zero-based array accessor.tag_suffix[N]
refers to the last N parts of the tag. It works like the usual zero-based array accessor.tag
refers to the whole tag.time
refers to stringanized event time.hostname
refers to machine’s hostname. The actual value is result of Socket.gethostname.