Details
-
New Feature
-
Resolution: Fixed
-
Major
-
1.2.3
-
None
Description
ILoggingEvent interface assumes that getTimeStamp() is in milliseconds.
Elasticsearch @timestamp resolution is in milliseconds too, see https://github.com/elastic/elasticsearch/issues/10005
As workaround people store second fraction in separate field in ES.
When sorting by @timestamp in ES events are ordered randomly within millisecond. In contrast writing to file at any precision preserves ordering.
Is it possible to increase timestamp resolution?
With current hardware nanosecond resolution is pretty good.
DETAILS:
We collect log events into Elasticsearch with project that writes timestamp via:
protected static String getTimestamp(long timestamp) {
return DATE_FORMAT.get().format(new Date(timestamp));
}
public class ClassicElasticsearchPublisher extends AbstractElasticsearchPublisher<ILoggingEvent> {
@Override
protected void serializeCommonFields(JsonGenerator gen, ILoggingEvent event) throws IOException {
gen.writeObjectField("@timestamp", getTimestamp(event.getTimeStamp()));
Only by changing ILoggingEvent or by providing alternative interface it would be possible to preserve timestamp in better resolution.
Attachments
Issue Links
- relates to (out)
-
LOGBACK-1599 LoggingEvent.getTimeStamp no longer returns milliseconds
- Resolved
- links to