serilog-sinks-elasticsearch icon indicating copy to clipboard operation
serilog-sinks-elasticsearch copied to clipboard

period (.) in scope keys getting converted to /

Open AceHack opened this issue 5 years ago • 5 comments

I'm using a Scope of Dictionary<string, object> and I have keys like Foo.Bar and that's getting converted to Foo/Bar in elastic search. How can I fix this.

AceHack avatar Feb 06 '19 05:02 AceHack

If you change these to no-ops then dots work fine in elastic search. Seems elastic search has allowed dots since somewhere around the 5.x version. Please allow for config option to allow dots.

https://github.com/serilog/serilog-sinks-elasticsearch/blob/67175c8f5d3c3d0783bb5c5996833cf1eea2597d/src/Serilog.Formatting.Elasticsearch/ElasticsearchJsonFormatter.cs#L133-L150

AceHack avatar Feb 06 '19 06:02 AceHack

Interesting indeed, ES allowed dots again. Care for a PR?

mivano avatar Feb 06 '19 14:02 mivano

Old issue, cleaning up. Still facing this issue, feel free to reopen.

mivano avatar Dec 16 '19 22:12 mivano

Looks like the conversation went stale in 2019 but just stating that this issue is still present in latest serilog version (2.9.0. at time of writing). @mivano, I am not too familiar with the codebase of serilog, but if you give some hint about how to check specific ES version, given that this is allowed since 5.x, I am willing to fix this and create a PR.

hskoro avatar Feb 02 '20 00:02 hskoro

In the v8 of the sink there is a way to detect the version: https://github.com/serilog/serilog-sinks-elasticsearch/blob/dev/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkState.cs#L245 Maybe that can be used to query for a specific version and determine what to do?

mivano avatar Feb 02 '20 21:02 mivano