serilog-sinks-elasticsearch
serilog-sinks-elasticsearch copied to clipboard
Timestamp with nanoseconds
Does this issue relate to a new feature or an existing bug?
- [ ] Bug
- [x] New Feature
*Not sure if it's a new feature, but it seems like that unless I'm missing some additional configuration.
What version of Serilog.Sinks.Elasticsearch is affected? Please list the related NuGet package.
Serilog 2.9.0 Serilog.Sinks.ElasticSearch 8.0.0
What is the target framework and operating system? See target frameworks & net standard matrix.
- [x] netCore 2.0
- [ ] netCore 1.0
- [ ] 4.7
- [ ] 4.6.x
- [ ] 4.5.x
Please describe the current behavior?
I get timestamps in ElasticSearch with millisecond precision (type date). That wouldn't bother me, but I've just noticed that logs are not ordered correctly when they are within the same millisecond.
Please describe the expected behavior?
Serilog internally seems to support nanoseconds (tested with format {Timestamp:yyyy-MM-dd HH:mm:ss.ffffff} for console sink) and I've noticed that since EleasticSearch 7.0 (or maybe even earlier) there is a dedicated data type date_nanos that is supposed to handle this case.
As we do detect which version we are running (or at least can indicate this), we should be able to support this specific field. Care for a PR?