2016-02-02 116 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爲我做到這一點?我在這裏描述的方式不會導致過濾文件,但配置會被接受。

回答