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

HTTP 400 when sending log to ElasticSearch 8.0.0

Open Belorus opened this issue 5 years ago • 8 comments
trafficstars

Versions: .NET Core 3.1 Serilog 2.9.0 Serilog.Sinks.ElasticSearch 8.1.0

Change in ElasticSearch 8.0 https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

Code that needs change: If I set TypeName to null (so that it doesn't get into resulting JSON) - everything works like a charm on both 7.x and 8.x

https://github.com/serilog/serilog-sinks-elasticsearch/blob/f8bfaf86bc28a27b8259459baa9a75db7729e342/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkState.cs#L75

Error screenshot: image

Belorus avatar Jul 11 '20 20:07 Belorus

Thanks for reporting. I have not used this version yet. Do you have a proposal on how to tackle this?

mivano avatar Jul 14 '20 18:07 mivano

One way could possible be to specify the Elastic version in the configuration. That is easy to understand but make it mandatory would cause a breaking change.

Making it optional and detect the version if not specified by calling GET / could also be an option to set the parameter if not specified?

Another option would be to have a default version and if possible configure the version in runtime? https://github.com/uken/fluent-plugin-elasticsearch#verify_es_version_at_startup

orjan avatar Sep 11 '20 15:09 orjan

We do have an detection of the version, so we can use that?

mivano avatar Sep 14 '20 08:09 mivano

@Belorus would you mind try to set TypeName = null in the latest version 8.4.0

https://github.com/serilog/serilog-sinks-elasticsearch/blob/dev/CHANGES.md

orjan avatar Sep 21 '20 17:09 orjan

Silly me just updated our dev ELK stack to 8.0.0 without checking things would work.

I see this is also tracked via #375

At the moment it looks like updating all our apps configuration via code will be needed: TypeName = null, BatchAction = ElasticOpType.Create

hastarin avatar Feb 22 '22 06:02 hastarin

I also ran into this problem and I'm reliant on the config files. However, it isn't possible to set TypeName to null. Is it possible to combine the use of configuraiton files and code config ?

digger73 avatar Feb 24 '22 12:02 digger73

@digger73 I'm not running Elastic any longer but if I'm not wrong, it must be set through code since it's not possible to deliberately set it to null trough configuration?

orjan avatar Feb 24 '22 15:02 orjan

@orjan I came to the same conclusion, that was looking for the solution of using both the app.config and configuration of the sink in the code, however I haven't gotten this to work. When using app.config the elasticsearch sink is registered as a restricted sink and the options set through code is registered as an elasticsearch sink.

digger73 avatar Feb 24 '22 15:02 digger73