我正在使用FluentD和Graylog GELF进行日志记录,但收效甚微。我想转发一个JSON文件:
<source>
@type tail
path /var/log/suricata/eve.json
pos_file /var/log/td-agent/suri_eve.pos # pos record
tag ids
format json
# JSON time stamp: 2016-02-01T11:52:49.157072+0000
# this timestamp is ruby's t.strftime("%Y-%m-%dT%H:%M:%S.%6N%z")
time_format %Y-%m-%dT%H:%M:%S.%6N%z
time_key timestamp # I show a JSON message below
</source>
<match **>
@type graylog
host 1.2.3.4 #(optional; default="localhost")
port 12201 #(optional; default=9200)
flush_interval 30
num_threads 2
</match>
这会启动,但会产生错误消息:
2016-02-01 15:30:11 +0000 [warn]:plugin / in_tail.rb:263:救援 convert_line_to_event: &#34; {\&#34;时间戳\&#34;:\&#34; 2016-02-01T15:27:09.000087 + 0000 \&#34; \&#34; flow_id \&#34; :51921072,\&#34; EVENT_TYPE \&#34;:\&#34;流\&#34; \&#34; src_ip \&#34;:\&#34; 10.1.1.85 \&# 34; \&#34; src_port \&#34;:59820,\&#34; DEST_IP \&#34;:\&#34; 224.0.0.252 \&#34; \&#34; dest_port \ &#34;:5355,\&#34;原\&#34;:\&#34; UDP \&#34; \&#34;流\&#34;:{\&#34; pkts_toserver \&#34:4,\&#34; pkts_toclient \&#34;:0,\&#34; bytes_toserver \&#34;:294,\&#34; bytes_toclient \&#34;:0, \&#34;开始\&#34;:\&#34; 2016-02-01T15:26:30.393371 + 0000 \&#34; \&#34;端\&#34;:\&#34 ; 2016-02-01T15:26:37.670904 + 0000 \&#34; \&#34;年龄\&#34;:7,\&#34;状态\&#34;:\&#34;新\&#34; \&#34;原因\&#34;:\&#34;超时\&#34;}}&#34; error =&#34;时间格式无效:value = 2016-02-01T15:27:09.000087 + 0000, error_class = ArgumentError,error =无效的strptime格式 - `%Y-%间 - %的dT%H:%M:%S%6N%Z&#39;&#34;
原始邮件如下所示:
{"timestamp":"2016-02-01T15:31:02.000699+0000","flow_id":52015920,"event_type":"flow","src_ip":"10.1.1.44","src_port":49313,"dest_ip":"224.0.0.252","dest_port":5355,"proto":"UDP","flow":{"pkts_toserver":2,"pkts_toclient":0,"bytes_toserver":128,"bytes_toclient":0,"start":"2016-02-01T15:30:31.348568+0000","end":"2016-02-01T15:30:31.759024+0000","age":0,"state":"new","reason":"timeout"}}
所以我检查了Ruby docs。我对FluentD不太熟悉,但据我所知,时间格式表达式应该适合吗?我试过了format=none
,但这也行不通。
答案 0 :(得分:1)
https://github.com/Graylog2/graylog2-server/issues/1761
这是Graylog2中保留字段(未记录)的错误/问题。 如果您发现时间戳类似的错误,请检查链接问题和开发响应。