MerlinDMC / fluent-plugin-input-gelf

A GELF input for Fluentd
MIT License
8 stars 15 forks source link

Parse microseconds #11

Closed alexpts closed 5 years ago

alexpts commented 5 years ago

Docs: http://docs.graylog.org/en/2.4/pages/gelf.html

timestamp: Seconds since UNIX epoch with optional decimal places for milliseconds; SHOULD be set by client library. Will be set to the current timestamp (now) by the server if absent.

Send data:

{"version":"1.0","host":"dev-stend","short_message":"xxx","timestamp":1542298163.379436,"_ctx_timestamp":1542298163.379436}

Fluend std out

2018-11-15 19:09:23.000000000 +0300 dd.gelf: {"version":"1.0","host":"dev-stend","short_message":"xxx","ctx_timestamp":1542298163.379436}

Plugin remove microsecond and set 000000.

alexpts commented 5 years ago

@MerlinDMC Can you check it?

I think convert to int remove microseconds here:

time = record.delete('timestamp').to_i if record.key?('timestamp')

**to_i**
alexpts commented 5 years ago

@griff Can you check it?

CarlGill commented 5 years ago

@alexpts I just finished looking into this, and got it working ( Properly parsing subsecond time ) with the following change:

-        time = record.delete('timestamp').to_i if record.key?('timestamp')
+        time = Fluent::EventTime.new(record.delete('timestamp').to_f ) if record.key?('timestamp')

I will work on creating a branch for this.

alexpts commented 5 years ago

@CarlGill thanks! I will wait new version plugin.

alexpts commented 5 years ago

@MerlinDMC Hi! Can you to publish new version with fix this problem?

MerlinDMC commented 5 years ago

v0.3.1 has been pushed to rubygems.org