2016-02-02 118 views
0

我有一个JSON文件,它是由一个工具生成的。我想在转发它之前删除一个属性。用FluentD删除密钥

<source> 
    @type tail 
    path /var/log/app/file.json 
    pos_file /var/log/td-agent/file.pos # pos record 
    tag file_json 
    format json 
</source> 

<match file_json> 
    @type exec 
    tag_key file_filtered 
    buffer_path /tmp/file_buffer.buf 
    command jq 'del(.timestamp)' 
    format json 
</match> 

<match file_filtered> 
    @type file 
    path /var/log/app/file_fwd.json 
    # time_slice_format %Y%m%d 
    # time_slice_wait 10m 
    # time_format %Y%m%dT%H%M%S%z 
    # compress gzip 
    # utc 
</match> 

我不知道所有的JSON属性,但我知道,我不能有timestamp领域。我用jq删除此属性模仿功能:

tail file.json | jq 'del(.timestamp)' 

能FluentD为我做到这一点?我在这里描述的方式不会导致过滤文件,但配置会被接受。

回答