-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support nanosecond resolution in fluentd #461
Comments
https://github.com/fluent/fluentd/commits/default-time-unit-option I have a branch to support millisecond resolution but I'm not sure this approach is good or not. Yeah, I also think Fluentd should support millisecond(and nanoseconds?) resolution. |
I'm not sure what the best approach is; initially I liked the idea of just making the existing timestamp floating point, but there is a risk that some plugins will not deal well with that. I also took a quick look and saw a few instances where existing plugins and tests use to_i to truncate. I can volunteer to help with development but it might take a few weeks before I have time to do it. I just wanted to get the ball rolling. I'd definitely vote for ns instead of ms; it's easy enough for someone to truncate if they want the latter. |
I realized mis-spoke above about floating point being able to handle nanoseconds - I was mixing up 'long double' (80-bit extended precision double, 64 bit mantissa) and standard double (64 bits, 53 bit mantissa). Given the current seconds since epoch, the latter can only represent microseconds, and that's generally what we have to work with. So, to support nanoseconds we'd need another representation like separate (integer) seconds and nanoseconds. |
argh, I hate the close-and-comment button :( |
What about representing the millisecond/nanosecond resolution as unix time (with millisecond/nanosecond presition)? |
How to represent nanosecond as unix time? |
In the most cases millisecond/microsecond resolution should be quite enough (comparing to seconds). To have support of nanosecond time there are multiple options:
|
I think there are two major problem about to represent nanosecond timestamp:
|
Honestly speaking, I don't think that it's really necessary to have nanotime representation. As for the nanoseconds - I would prefer custom made class as it adds more flexibility comparing to other approaches. P.S. What about adding "version" field to the protocol? It should help for the plugin implementers to decide how to parse the incoming message? |
I agree. millisecond precision is enough for almost users but nanoseconds support is also good.
Does this mean forward plugin protocol? |
Agree too.
That's too, but mainly - internal event representation (agree that "protocol" is not a correct word in that case). The version is a pretty useful feature to support backward compatibility too, For example, fluentd can automatically convert v2 events which support nanoseconds into v1 events which support only seconds before passing the event to a plugin, if this plugin does not support v2 events handling. |
Another option is 64-bit integer "nanoseconds since the epoch" like Ruby Time, or will we have trouble making sure it doesn't get converted to float somewhere? In any case, I think if we use a new representation it should use nanoseconds, because it won't be any more difficult than micros. microseconds does have the advantage that it could work with the existing protocol, although there are definitely places in the existing code that truncate the time to integer. |
Maybe 64bit integer as nanoseconds seems hard to use. |
We have a plan to release fluentd v0.12 at Dec 12. |
+1 for milliseconds in fluentd I am using Fluentd to store logs in elastic search and events are out of order without better time resolution. I worked around this using http://stackoverflow.com/q/27928479/2848111 |
We have two discussion points. millisecond or nanosecond?From our experience, milliseconds is enough for popular use-cases. How to implement it?For millisecond, using floating point instead of integer is enough.
This is straightforward approach.
This is light-weight approach so serialized data is smaller than above. In fluentd, we will implement |
I will try to check the performance of nanosecond approach. |
- timeNanos is deprecated because the 53 bit mantissa used for doubles does not have sufficient precision to represent the current time in nanoseconds past the unix epoch (which currently requires 61 bits). - instead, we now support formats with split seconds and nanoseconds: - timestampSeconds, timestampNanos - timestamp { seconds, nanos } In both cases, the "seconds" part represents seconds since the unix epoch, and the "nano" part is the nanosecond component only (0..999999999). Managed VMs is using the latter, but it can only be ingested via json/msgpack/etc, while the former is suitable for use in an in_tail regex. This should be considered an interim solution until fluent/fluentd#461 is resolved.
Use raw Time.now.to_f instead of Engine.now until fluent/fluentd@c9be93c is merged or fluent/fluentd#461 resolved
does fluentd support millisecond now? |
Not now. We have a plan to add sub-second support since v0.14. |
memo: Need faster TimeParser because cache doesn't work with sub-second support. |
We consider adding nano-second type to msgpack ext in fluentd. |
@mururu now working on this issue. |
Continue to discuss this issue via #653 PR! |
Hi, do you still plan to backport this to 0.12 per the comment above? |
@mr-salty Sorry, I missed your comment. |
Close because this is implemented since v0.14. |
@repeatedly Is there anything special that needs to be done to make this work? I can't find any docs covering this. I'm using v0.14.8 and have the following config:
But I don't end up with millisecond precision - I still only get resolution up to the second. As you can see from my config, I'm using the AWS Elasicsearch plugin, but I don't see why that would make a difference. |
@yissachar |
@cosmo0920 Thanks for the tip. I've opened uken/fluent-plugin-elasticsearch#222 |
Currently fluentd timestamps have second granularity; this is a feature request to support nanoseconds (or milliseconds, although personally I prefer the former).
See also #96 - there was some discussion there of opening a new issue but I don't see one so I thought I would do it. Proposals there were passing milli/nanoseconds independent of the existing timestamp, or treating the existing timestamp as floating point (currently good enough for 1/4ns granularity assuming unix epoch time).
The text was updated successfully, but these errors were encountered: