Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

HTTP 400 when sending log to ElasticSearch 8.0.0 #345

Open
Belorus opened this issue Jul 11, 2020 · 8 comments
Open

HTTP 400 when sending log to ElasticSearch 8.0.0 #345

Belorus opened this issue Jul 11, 2020 · 8 comments

Comments

@Belorus
Copy link

Belorus commented Jul 11, 2020

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

@mivano
Copy link
Contributor

mivano commented Jul 14, 2020

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

@orjan
Copy link
Contributor

orjan commented Sep 11, 2020

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

@mivano
Copy link
Contributor

mivano commented Sep 14, 2020

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

@orjan
Copy link
Contributor

orjan commented Sep 21, 2020

@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

@hastarin
Copy link

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

@digger73
Copy link

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 ?

@orjan
Copy link
Contributor

orjan commented Feb 24, 2022

@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?

@digger73
Copy link

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants