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

v9.0.0 fails template creation with ES v7 with ElasticsearchClientException #518

Open
2 of 8 tasks
AlexGoris-KasparSolutions opened this issue Mar 8, 2023 · 3 comments
Open
2 of 8 tasks

Comments

@AlexGoris-KasparSolutions

Does this issue relate to a new feature or an existing bug?

  • Bug
  • New Feature

What version of Serilog.Sinks.Elasticsearch is affected? Please list the related NuGet package.
9.0.0

What is the target framework and operating system? See target frameworks & net standard matrix.

  • netCore 2.0
  • netCore 1.0
  • 4.7
  • 4.6.x
  • 4.5.x
  • 6.0

Please describe the current behavior?
When starting with an ES v7 server which doesn't have any serilog template configure, the sink tries to create the template, this fails with the following exception:

2023-03-08T10:12:49.7376289Z Failed to create the template. Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: PUT /_template/serilog-events-template?include_type_name=true. ServerError: Type: illegal_argument_exception Reason: "Malformed [mappings] section for type [dynamic_templates], should include an inner object describing the mapping"
   at Elasticsearch.Net.Transport`1.HandleElasticsearchClientException(RequestData data, Exception clientException, IElasticsearchResponse response)
   at Elasticsearch.Net.Transport`1.FinalizeResponse[TResponse](RequestData requestData, IRequestPipeline pipeline, List`1 seenExceptions, TResponse response)
   at Elasticsearch.Net.Transport`1.Request[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters)
   at Elasticsearch.Net.ElasticLowLevelClient.DoRequest[TResponse](HttpMethod method, String path, PostData data, IRequestParameters requestParameters)
   at Elasticsearch.Net.NamespacedClientProxy.DoRequest[TResponse](HttpMethod post, String url, PostData body, IRequestParameters params)
   at Elasticsearch.Net.Specification.IndicesApi.LowLevelIndicesNamespace.PutTemplateForAll[TResponse](String name, PostData body, PutIndexTemplateRequestParameters requestParameters)
   at Serilog.Sinks.Elasticsearch.ElasticsearchSinkState.RegisterTemplateIfNeeded() in C:\Users\ag\workspaces\oss\serilog-sinks-elasticsearch\src\Serilog.Sinks.Elasticsearch\Sinks\ElasticSearch\ElasticsearchSinkState.cs:line 177

Please describe the expected behavior?
Template creation should succeed without exceptions.

If the current behavior is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem
Running the sample project with dotnet run, changing nothing other than the ConnectionStrings:elasticsearch parameter in appsettings.json against a local docker container running the sebp/elk:7.17.5 docker image.

Make sure you have the default serilog-events-template template deleted as if you've previously used 8.4.1 of this sink the template will already be there and won't be recreated.

@nenadvicentic
Copy link
Contributor

@AlexGoris-KasparSolutions What configuration do you use for the sink in your .NET project when this error happens?

@AlexGoris-KasparSolutions
Copy link
Author

@AlexGoris-KasparSolutions What configuration do you use for the sink in your .NET project when this error happens?

As described, I started from the sample project of this repo, only configured the ConnectionStrings:elasticsearch to point at my local elk stack (running sebp/elk:7.17.5) and started it with dotnet run

So the configuration is the one which is found in Program.cs line 33

@nenadvicentic
Copy link
Contributor

@AlexGoris-KasparSolutions Thank you for the details. I've added few comments to your pull request: #519 (review), if it's possible to round it up properly.

mivano pushed a commit that referenced this issue May 10, 2023
…ientException #518 (#533)

Co-authored-by: AlexGoris-KasparSolutions
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

2 participants